# akoo's profile - activity

2013-12-11 01:17:36 -0500 commented answer how to select a specific bounding box

Yeah pyro, I've realized this solution gives me some false positives. I guess I would do any other thing to avoid these false positives. And how can I pass the bounding boxes to the function for computing the histogram, because they are not Mat, as you can see in the code. Thanks

2013-12-10 03:15:38 -0500 commented answer how to select a specific bounding box

I'm trying to use an OCR to recognize these characters from inside the license plate that is the reason I want to select only the bounding box containing characters, to run after an OCR engine. Anyway I think I've found one way to select it. It has worked with some pictures, not only this. I have calculated the aspect ratio of a bounding boxes, and if it is between 3 and 6 then is a possible license plate. Thanks pyro.

2013-12-10 01:17:03 -0500 asked a question how to select a specific bounding box

Hi everybody, I'm doing a program to obtain bounding boxes and once obtained these bounding boxes I would like to select only one of these. Is there any way to select only the desired bounding box. For example, in the attached picture, I would like to select only the bounding box where is a license plate inside, but I don't know how can I do that. Any help? Thanks in advance.

Mat findBox(Mat imagen){

//blur(imagen,imagen,Size(3,3));
Mat threshold_output;
vector<vector<Point> > contours;
vector<Vec4i> hierarchy;

/// Detect edges using Threshold
threshold( imagen, threshold_output, 140, 255, THRESH_BINARY );
/// Find contours
findContours( threshold_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );

/// Approximate contours to polygons + get bounding rects and circles
vector<vector<Point> > contours_poly( contours.size() );
vector<Rect> boundRect( contours.size() );
vector<Point2f>center( contours.size() );

for( uint i = 0; i < contours.size(); i++ ){
approxPolyDP( Mat(contours[i]), contours_poly[i], 3, true );
boundRect[i] = boundingRect( Mat(contours_poly[i]) );
}
/// Draw polygonal contour + bonding rects
Mat drawing = Mat::zeros( threshold_output.size(), CV_8UC3 );
cvtColor(imagen,imagen,CV_GRAY2BGR);
Scalar colorRed( 0,0,255);
Scalar colorWhite( 255,255,255);
Point inici;Point fin;
//Point un, dos;
float ratio;

for( uint i = 0; i< contours.size(); i++ ){

double area=contourArea(contours[i]); //calculamos area de contornos
cout<<area<<endl;
/*si mayor que 1000 tengo la placa matricula
* si mayor que 200 los caracteres y calculamos el aspect ratio */
if( area >= 1000 ){
if(area <= 8000){

//Point uno(boundRect[i].x,boundRect[i].y);
//inici=uno;
//cout<<"Bound:"<<boundRect[i].br()<<" "<<inici.y<<endl;
drawContours( drawing, contours_poly, i, colorWhite, 1, 8, vector<Vec4i>(), 0, Point() );
//rectangle( imagen, boundRect[i].tl(), boundRect[i].br(), colorRed, 1, 8, 0 );
//Point dos(boundRect[i].br());
//fin=dos;

ratio = boundRect[i].width/boundRect[i].height;
if(ratio >= 3){
if(ratio <= 6){
cout<<"ratio:"<<ratio<<endl;
rectangle( imagen, boundRect[i].tl(), boundRect[i].br(), colorRed, 1, 8, 0 );

Point p1(boundRect[i].x,boundRect[i].y);
Point p2(boundRect[i].br());
inici=p1;
fin=p2;
}
}
}
}

}

imshow("Image",imagen);
return drawing;


}

2013-12-05 04:09:32 -0500 asked a question how to draw rectangles from find countours

Hi all, I'm doing a project where i obtain contours of an image and draw the rectangle of minimum area which contains that contours. Now I would like to draw only some rectangles, I would like to avoid rectangles with small area for having a better detection, but I don't know how to draw only the greater rectangles obtained. As you can see in the attached image I would like to draw only the rectangles that contain some character. Some help would be appreciated. Thanks in advance.

## I attach the code I have for finding contours and draw the rectangles, as well as the image obtained.

Mat encuentraRect(Mat imagen){

blur(imagen,imagen,Size(3,3));

Mat threshold_output;

vector<vector<Point> > contours;

vector<Vec4i> hierarchy;

/// Detect edges using Threshold
threshold( imagen, threshold_output, 100, 255, THRESH_BINARY );
/// Find contours
findContours( threshold_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );

/// Find the rotated rectangles for each contour
vector<RotatedRect> minRect( contours.size() );

for( uint i = 0; i < contours.size(); i++ ){
minRect[i] = minAreaRect( Mat(contours[i]) );

}

/// Draw contours + rotated rects
Mat drawing = Mat::zeros( threshold_output.size(), CV_8UC3 );
for( uint i = 0; i< contours.size(); i++ ){
Scalar red(0,0,255) ;
Scalar white(255,255,255);
// contour
drawContours( drawing, contours, i, white, 1, 8, vector<Vec4i>(), 0, Point() );

// rotated rectangle
Point2f rect_points[4];
minRect[i].points( rect_points );
float angle;

for( int j = 0; j < 4; j++ ){
line(region , rect_points[j], rect_points[(j+1)%4], red, 1, 8 );

}
}
return region;
//imshow("contornos",drawing);


}

2013-10-30 08:11:25 -0500 answered a question OCR Character Segmentation for cursive handwriting

Hi 123ezone, I am doing a license plate recognition using an OCR too and at this moment I'd like to use horizontal projection. Could you tell me please how have you done it?

Thanks

2013-10-30 04:56:26 -0500 asked a question Tesseract engine does not work properly

Hi all, I am trying to write a software to recognize some text from an image, but when I binarize the image and I call to tesseract engine, this does not recognize text in image. Does somebody know why text it is not recognized? Must I do something extra to recognize? I leave the image I am trying to recognize text. tesseract output is: "24"

I've also tried with another image like this:

And the output is also wrong. Output: "L I"

Could anybody help me?

2013-10-01 07:20:03 -0500 commented question How to take an snapshot from a ethernet cam?

I know cuenta is not the same value now, I have changed that just after post the code here.

2013-10-01 05:30:15 -0500 commented question How to take an snapshot from a ethernet cam?

Thank you berak! It works fine!

2013-10-01 05:06:17 -0500 asked a question How to take an snapshot from a ethernet cam?

Hello everybody,

I've got a code where I show a video from a camera, but now I want to take a snapshot when a key is pressed, but I don't know exactly what function I need to use and how. Could anyone help me please?

Thanks. I post my code.

int main( ) {

  VideoCapture vcap;

std::cout << "Error abriendo stream de video o archivo" << std::endl;
return 0;
}
while (true) {
std::cout << "No frame" << std::endl;
cv::waitKey();
}
imshow("original", image);

if (waitKey(1) >= 0){
//TAKE A PHOTO
TakePhoto();
}
}
return 0;


## }

Hi again, The code to take snapshots it works fine, I can take a photo when a key is pressed, but now I'm trying to recognize text in that photo using tesseract engine and I'm having an error like this:

Error: Illegal min or max specification! signal_termination_handler:Error:Signal_termination_handler called:Code 5002

I've only just added the code for text recognition within the waitkey if as follows:

if (waitKey(10) >= 0){

            imwrite( format("foto_%3d.png",cuenta++), image); //take snapshot when key is pressed

// initilize tesseract OCR engine
tesseract::TessBaseAPI *myOCR = new tesseract::TessBaseAPI();

if (myOCR->Init(NULL, "spa")) {
fprintf( stderr, " Could not intialize tesseract.\n" );
exit(1);
}

namedWindow("tesseract-opencv", 0);

// set region of interest (ROI), i.e. regions that contain text
Rect text1ROI(162, 110, 157 , 129);

// recognize text
myOCR->TesseractRect( imagen.data, 1, imagen.step1(), text1ROI.x, text1ROI.y, text1ROI.width, text1ROI.height);
const char *text1 = myOCR->GetUTF8Text();

// remove "newline"
string t1(text1);
t1.erase( std::remove(t1.begin(), t1.end(), '\n'), t1.end() );

// print found text
printf("text: \n");
printf( "%s",t1.c_str() );
printf("\n");
}


Any idea of that error????

Thanks

2013-09-30 01:10:55 -0500 commented question How to link tesseract to Eclipse in Ubuntu 12.04 ??

What are the leptonica libs?? Could you tell me what libraries I need to add?