Ads

Selasa, 31 Juli 2018

Tracking Circle with OPENCV Camera


Detection and Tracking circles with the Camera using Opencv - this time admin posts Detect and Tracking circles with Camera using Open CV or can be called Tracking Hough Circle with Camera.
In this tutorial, we will definitely be faced with a camera, for sample open camera coding, can be seen in the previous article "Access webcam camera with Open CV". This article is a combination of loop detection and camera. wow, how about it, sir? so we can detect circles in realtime with the camera and issue the position value of the circle in realtime, of course. Just look at the coding below.

Source Code [Raw
import cv2

videoCam = cv2.VideoCapture(1)

while True:
    cond, frame = videoCam.read()
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    circles = cv2.HoughCircles(gray, cv2.HOUGH_GRADIENT, 1.2, 100)

    if circles is not None:
        circles = np.round(circles[0, :]).astype("int")
        for (x,y,radius) in circles:
            cv2.circle(frame, (x,y),radius, (0,255,0), 4)
            cv2.rectangle(frame, (x - 5, y - 5), (x + 5, y + 5), (0,128,255),1)
            nilaix = str(x)
            nilaiy = str(y)
            nilair = str(radius)
            if radius > 10:
                print('nilai x = ' + nilaix + ' | nilai y = ' + nilaiy + ' | nilai radius = ' + nilair)

    
    cv2.imshow('Original Video', frame)
    
    
    #cv2.imshow('Gray Video', gray)

    k = cv2.waitKey(1) & 0xff
    if k == ord('q'):
        break

videoCam.release()
cv2.destroyAllWindows()

Note :
Here I use Video Capture (1). because "0" for cameras on laptops, and "1" for external cameras.
Thanks For Reading tutorial "Detection and Tracking circles with the Camera using Opencv" .

Tag :

  • OpenCv Camera
  • OpenCV Pyhton Camera
  • Opencv python tracking circle

    Choose :
  • OR
  • To comment
Tidak ada komentar:
Write komentar