seq.add(new RgbAvgGray());
seq.add(new Gray8HistEq());
seq.add(new Gray8HorizVertContrast(5, 2, -8, 3));
seq.add(new Gray16Threshold(20));
seq.push(rgb);
Gray8ConnComp gcc = new Gray8ConnComp();
Image imThresh = seq.getFront();
Gray8Rgb g2r = new Gray8Rgb();
g2r.push(imThresh);
if (DetectBarcode.bDebug) {
Debug debug = new Debug();
debug.toFile((RgbImage)g2r.getFront(), "test.jpg");
}
gcc.push(imThresh);
if (gcc.getComponentCount() == 0) {
return false;
}
// get component which is largest than the minimum size and
// closest to a 4/3 ratio of width to height
Rect rReduced;
int nBestDiff = Integer.MAX_VALUE;
this.rDetected = null;
for (int i=0; i<gcc.getComponentCount(); i++) {
rReduced = gcc.getComponent(0);
// we detected the barcode at reduced resolution
// for speed. Stretch the rectangle back to its
// original size
Rect rThisDetected = new Rect(
(rReduced.getLeft() * rgb.getWidth()) / nReducedWidth,