Last post Mar 31, 2010 11:23 AM by florinlabou
Mar 31, 2010 01:00 AM|nitinpog|LINK
I am currently developing an Bar Code detection application in sliverlight by writing some custom code to detect Bar Code.
The code works fine for images which we supply statically ( hardcoded the images path to location from the project or allowing the user to select image from File Dialog)
These above images are of good resolution and clarity so the program decodes to correct Bar Code value.
The main prolem is when i use the Web Cam and capture the bar code from the camera.
The image captured from the camera is of size 320 * 240 and camera is of resolution between 1.3-2 mega pixel.
Before passing the image to main bar code algorithm i processed the image to sharpen sample code is as below .
public static Bitmap sharpen(Bitmap image)
Bitmap sharpenImage = new Bitmap(image.Width, image.Height);
int filterWidth = 3;
int filterHeight = 3;
int w = image.Width;
int h = image.Height;
double[,] filter = new double[filterWidth, filterHeight];
filter[0, 0] = filter[0, 1] = filter[0, 2] = filter[1, 0] = filter[1, 2] = filter[2, 0] = filter[2, 1] = filter[2, 2] = -1;
filter[1, 1] = 9;
double factor = 1.0;
double bias = 0.0;
Color[,] result = new Color[image.Width, image.Height];
for (int x = 0; x < w; ++x)
for (int y = 0; y < h; ++y)
double red = 0.0, green = 0.0, blue = 0.0;
for (int filterX = 0; filterX < filterWidth; filterX++)
for (int filterY = 0; filterY < filterHeight; filterY++)
int imageX = (x - filterWidth / 2 + filterX + w) % w;
int imageY = (y - filterHeight / 2 + filterY + h) % h;
red += imageColor1.R * filter[filterX, filterY];
green += imageColor1.G * filter[filterX, filterY];
blue += imageColor1.B * filter[filterX, filterY];
int r = Math.Min(Math.Max((int)(factor * red + bias), 0), 255);
int g = Math.Min(Math.Max((int)(factor * green + bias), 0), 255);
int b = Math.Min(Math.Max((int)(factor * blue + bias), 0), 255);
result[x, y] = Color.FromArgb(r, g, b);
for (int i = 0; i < w; ++i)
for (int j = 0; j < h; ++j)
sharpenImage.SetPixel(i, j, result[i, j]);
But still the problem persists. Tried to search more free image processing algorithms/library so as to apply it on the image before detecting the bar code but found few.
Please help with any help or clue so that can help to resolve the issue.
Thanks & Regards,
Mar 31, 2010 11:23 AM|florinlabou|LINK
Try AForge.NET Image processing library. It provides a wide range of filters.
The framework has video capture support:
I hope this will help.