How to get auto generate measurement on object with openCV?
Here is a code where I want to implement the object measurement, but I don't have any idea on what function that I've to use and how to code it and how to make it auto generate. There's anyone can help me? Thank you in advanced.
cv::VideoCapture cap;
if (!cap.isOpened()) // check if succeeded to connect to the camera
CV_Assert("Can't open Web-Cam");
double CamHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT);
double CamWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH);
//Display text on the screen function
int imgW = 650;
int imgH = 50;
int fontFace = FONT_HERSHEY_PLAIN;
double fontScale = 1.5;
int thickness = 2;
Point textOrg(imgW/5, imgH/1.3);
int value=10;
string someText = format("Dimension: %d ", value); //Display the dimension (output)
putText(frame, someText, textOrg, fontFace, fontScale, Scalar::all(255), thickness, 8);
imshow("Object Measurement",frame);;
You will get some idea from here.
Hi haris, actually here is the code that I've referred just now. I got a lot of error. There's anything wrong from what I did?
From where did you get the code?, what are the errors?
I got that code from the link that u asked me to refer. The error is just undefined 'j'. But I don't know whether I arrange the code correct or not.
I didn’t find any code there, and the link will give you an idea how to do it according to the scenario.
Yes. But sorry. I still didn't get the idea of how to measure the object..
Please explain your scenario....
This what I mean to do. http://www.youtube.com/watch?v=bcswZLwhTUI
In that probably the camera in fixed distance and the object to measure always will be in same plane(same distance from the camera), so first place reference object on the plane and calculate pixel/size(m or mm) ratio, and when object to measure come to the scene find it's length in pixels and convert it to metre or mm using the ratio. For finding the object bounding box you can use contour processing.
How to implement it on the code? Sorry, but I don't know how. Hope you can help me. Thank you in advance.