my decoder cannot detect picture of webcam. i change the brightness and contrast. some time can detect but some times cannot. i know thats picture problem. now i edit the image but its useless. can i change webcam setting or do any changes to my code..here is my code....
private void btnDecode_Click_1(object sender, EventArgs e)
{
try
{
DeviceManager manager = new DeviceManagerClass();
Device d = null;
foreach (DeviceInfo info in manager.DeviceInfos)
{
d = info.Connect();
}
Item item = d.ExecuteCommand(CommandID.wiaCommandTakePicture);
foreach (string format in item.Formats)
{
WIA.ImageFile imagefile = item.Transfer(format) as WIA.ImageFile;
// if (File.Exists("d:\\\\test.jpg"))
{
// picDecode.Image = null;
// File.Delete("d:\\\\test.jpg");
}
imagefile.SaveFile("d:\\\\4.jpg");
Bitmap image = new Bitmap("d:\\\\4.jpg");
Bitmap bm = new Bitmap(image, 200, 150);
System.Drawing.Bitmap TempBitmap = bm;
float brightness = 0.6f;
float constrast = 6f;
System.Drawing.Bitmap NewBitmap = new System.Drawing.Bitmap(TempBitmap.Width, TempBitmap.Height);
System.Drawing.Graphics NewGraphics = System.Drawing.Graphics.FromImage(NewBitmap);
float\[\]\[\] FloatColorMatrix ={
new float\[\] {constrast, 0, 0, 0, 0},
new float\[\] {0, constrast, 0, 0, 0},
new float\[\] {0, 0, constrast, 0, 0},
new float\[\] {0, 0, 0, constrast, 0},
new float\[\] {brightness, brightness, brightness, 1, 1}
};
System.Drawing.Imaging.ColorMatrix NewColorMatrix = new System.Drawing.Imaging.ColorMatrix(FloatColorMatrix);
System.Drawing.Imaging.ImageAttributes Attributes = new System.Drawing.Imaging.ImageAttributes();
Attributes.SetColorMatrix(NewColorMatrix);
NewGraphics.DrawImage(TempBitmap, new System.Drawing.Rectangle(0, 0, TempBitmap.Width, TempBitmap.Height), 0, 0, TempBitmap.Width, TempBitmap.Height, System.Drawing.