Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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);;