Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

barcode detection....i wanted to draw a red box around a barcode image...showing that the barcode is detected from the image...

Asked by Elysi Cochin on 17 Oct 2012

i wanted to draw a red box around a barcode image... showing that the barcode is detected from the image... my image is a barcode image itself... (means barcode is not a portion of my image..the full image is barcode itself...

0 Comments

Elysi Cochin

Products

No products are associated with this question.

2 Answers

Answer by michael scheinfeild on 17 Oct 2012
Accepted answer

hold on use line command you have option of color

2 Comments

Elysi Cochin on 17 Oct 2012
Irgb = imread('15wmqe9.jpg');
Irgb = imread('av672a.jpg');
Iresize = imresize(Irgb,0.33);
Igray = double(rgb2gray(Iresize));
[dIx dIy] = gradient(Igray);
B = imabsdiff(abs(dIx),abs(dIy));
H = fspecial('gaussian', 20, 10);
C = imfilter(B, H);
Th = max(C(:));
D = C < Th-10;
stat = regionprops(~D,'Area','BoundingBox');
for i = 1 : numel(stat), 
    Iarea(i) = stat(i).Area;
end
[C I] = max(Iarea);
bb = stat(I).BoundingBox;
imshow(Iresize); hold on
rectangle('position',bb,'edgecolor','r');

Now my error code is:

??? Index exceeds matrix dimensions.
Error in ==> Untitled6 at 20 
bb = stat(I).BoundingBox;

Can u rectify the above error for me?

Image Analyst on 17 Oct 2012

What's the URL where you uploaded 15wmqe9.jpg?????

michael scheinfeild
Answer by arron on 2 Jul 2013
Edited by arron on 2 Jul 2013

Start to Detect Barcodes:

    Open and run your Microsoft Visual Studio;
    Choose either "Visual C# Projects" in "New Project" dialog box;
    Choose "Windows Application" in the "Templates" List and name it "YiigoImagingBarcodeReadCsharp";
    Right-click on the "References" folder, and select "Add Reference..." from the context menu in the "Solution Explorer" window;
    In the "Add Reference" dialog box, select the ".NET" tab and browse to Yiigo.Imaging.Net.dll library and Yiigo.Imaging.Net.Barcode.Read.dll ;
    Add it to your Visual C# applications;
    Call Yiigo .NET Image Namespace & Copy those following codes:
using System.IO;
using System.Drawing.Printing;
using Yiigo.Imaging;
using Yiigo.Imaging.Processing;
using Yiigo.Imaging.BarcodeRead;
// Read a barcode
YiigoImage BarcodeImage = new YiigoImage("barcode.tif");
using (BarCodeRead barcode = new BarCodeRead (BarcodeImage))
{
string fileName = @"C:\Users\Public\Documents\LEADTOOLS Images\Barcode.tif"
ReadOpts ReadBarcode = new ReadOpts();
ReadBarcode.Direction = Directions.LeftToRight;
ReadBarcode.Symbology = Symbologies.Code128;
Barcode[] bars = barcode.ReadBars(options);
for (int i = 0; i < bars.Length; i++)
System.Console.WriteLine(bars[i].ToString());
}
// Return check digit
using (BarCodeRead barcode = new BarCodeRead (BarcodeImage))
{
ReadOpts ReadBarcode = new ReadOpts();
ReadBarcode.Direction = Directions.LeftToRight;
ReadBarcode.Symbology = Symbologies.Code39;
Barcode[] bars = barcode.ReadBars(options);
for (int i = 0; i < bars.Length; i++)
System.Console.WriteLine(bars[i].ToString());
}
public string ValidateMod43(string barcode) { int subtotal = 0; const string charSet = "CODE-39"; 
for (int i = 0; i < barcode.Length; i++) { subtotal += charSet.IndexOf(barcode.Substring(i, 1)); } 
return charSet.Substring(subtotal%43, 1); }
// Read barcode properties
YiigoImage BarcodeImage = new YiigoImage("barcode.tif");
using (BarCodeRead barcode = new BarCodeRead (BarcodeImage)
{
string fileName = @"C:\Users\Public\Documents\LEADTOOLS Images\Barcode.tif"
options.Direction = Directions.LeftToRight;
options.Symbology = Symbologies.Code128;
Barcode[] bars = barcode.ReadBars(options);
if (bars.Length == 0)
{
options.Direction = Directions.RightToLeft;
bars = barcode.ReadBars(options);
}
}

Try this barcode detecting SDK using those CODE. I hope you success.

Best regards, Arron

0 Comments

arron

Contact us