# Revision history [back]

### How to crop digits automatically in sequence for recognition?

I am trying to implement Automatic Digit Recognition. For this I am using C++ with OpenCv. I have successfully trained SVM classifier ,successfully can able to crop the digits from the group of digits. Manually it works fine. But my problem is when i am trying to extract the individual digits the output is coming in random manner , not maintaining the sequence. The below attached image is the output in which bounding box successfully drawn on individual digits and while extracting the individual digits the sequences should be i.e. for the number 0240408:-1st Position= 0, 2nd Position=2, 3rd Position=4, 4th Position=0, 5th Position=4, 6th Position= 0, 7th Position=8. But I am not getting the same, rather i am getting 1st Position= 8, 2nd Position= 0, 3rd Position= 4, 4th Position= 0, 5th Position= 0, 6th Position= 4, 7th Position= 2. Due to which the output number becomes= 8040042. Please suggest any techniques to overcome this problem.

 2 No.2 Revision berak 32993 ●7 ●81 ●312

### How to crop digits automatically in sequence for recognition?

I am trying to implement Automatic Digit Recognition. For this I am using C++ with OpenCv. I have successfully trained SVM classifier ,successfully can able to crop the digits from the group of digits. Manually it works fine. But my problem is when i am trying to extract the individual digits the output is coming in random manner , not maintaining the sequence. The below attached image is the output in which bounding box successfully drawn on individual digits and while extracting the individual digits the sequences should be i.e. for the number 0240408:-1st 0240408:-

1st Position= 0,
2nd Position=2,
3rd Position=4,
4th Position=0,
5th Position=4,
6th Position= 0,
7th Position=8.
Position=8.


But I am not getting the same, rather i am getting

1st Position= 8,
2nd Position= 0,
3rd Position= 4,
4th Position= 0,
5th Position= 0,
6th Position= 4,
7th Position= 2.
2.


Due to which the output number becomes= 8040042. Please suggest any techniques to overcome this problem.

//here I am finding the bounding boxes

for( size_t i = 0; i < contours.size(); i++ )
{
approxPolyDP( Mat(contours[i]), contours_poly[i], 5, false );
boundRect[i] = boundingRect( Mat(contours_poly[i]) );
rectangle( grayImage, boundRect[i].tl(), boundRect[i].br(), Scalar(0,255,0),2, 8,0 );

}

//Here I am cropping the bounded region and saving it with the a number.jpg

for(int i=0;i<kirti;i++)
{
if(boundRect[i].width>50 && boundRect[i].height>50)
{
ROI[i]= grayImage(boundRect[i]);
string name= format("%d.jpg",i);
imwrite(name,ROI[i]);
cout<<boundRect[i].height<<endl;
}
}