I have a video with a serial number. Like in the picture. How I can with openCV detect the position of this patron. The only thing that I need is detect the location of this patron. Always this patron will have 12 numbers and will be white.
using Morphological Transformations you can find location of numbers.
try the code below (not a perfect code, it is just for instruction)
#include <opencv2/opencv.hpp>
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
Mat src=imread("dnpaP.jpg");
Mat thresh = src.clone();
dilate(thresh,thresh,Mat(),Point(-1,-1), 5);
erode(thresh,thresh,Mat(),Point(-1,-1), 5);
cvtColor(thresh, thresh, COLOR_BGR2GRAY);
threshold(thresh, thresh, 200, 255, THRESH_BINARY);
erode(thresh,thresh,Mat(),Point(-1,-1), 3);
dilate(thresh,thresh,Mat(),Point(-1,-1), 3);
vector<vector<Point> > contours;
findContours(thresh.clone(), contours, RETR_LIST, CHAIN_APPROX_SIMPLE);
for( size_t i = 0; i< contours.size(); i++ )
{
Rect boundingRect_ = boundingRect( contours[i] );
if(boundingRect_.width > boundingRect_.height * 12)
rectangle(src,boundingRect_,Scalar(0,0,255),2);
}
imshow("thresh",thresh);
imshow("src",src);
waitKey();
}