简体   繁体   中英

How do I find the circle object diameter in mm from IP camera streaming using Python?

I had already tried by measuring the size of an object (in inches) with Known width of a reference object .I am done by referring this link https://www.pyimagesearch.com/2016/03/28/measuring-size-of-objects-in-an-image-with-opencv/ . But I don't know how to detect circle object and find the diameter of the object using OpenCV in python.Please,help me Thanks in Advance.

Here is my code:

if pixelsPerMetric is None:
                pixelsPerMetric = dB / 8.070866
            dimA = dA / pixelsPerMetric
            dimB = dB / pixelsPerMetric

            print("dd",dimA,dimB)
            # draw the object sizes on the image
            cv2.putText(orig, "{:.4f}in".format(dimA),
                        (int(tltrX - 15), int(tltrY - 10)), cv2.FONT_HERSHEY_SIMPLEX,
                        0.65, (255, 0, 255), 2)
            cv2.putText(orig, "{:.4f}in".format(dimB),
                        (int(trbrX + 10), int(trbrY)), cv2.FONT_HERSHEY_SIMPLEX,
                        0.65, (255, 0, 255), 2)


            cv2.imshow("Image", orig)
            cv2.waitKey(0)

Does a hough circle transform would fit your needs ? -> see here

Regards,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM