Ball/circle shape tracking in video or live feed with OpenCV (Python) -


as task school our group has create application knows when goal scored. means ball shaped object passes line.

first attempting input video, opencv track ball, , output video.

i have put bunch of other code snippets have found on stackoverflow, doesn't work.

i creating new post because other related threads either c++ or use colour detection instead of shape detection use. can't find clear answer on outputting video file when turned series of images.

following code have far:

import cv2 import numpy np  cap = cv2.videocapture('bal.mp4')   fourcc = cv2.videowriter_fourcc(*'xvid') out = cv2.videowriter('output1.avi',fourcc, 20.0, (640,480))  while(1):      # take each frame     ret, frame = cap.read()     if ret == true:         if ret == 0:             break           frame = cv2.medianblur(frame,5)         cimg = cv2.cvtcolor(frame,cv2.color_bgr2gray)         circles = cv2.houghcircles(cimg,3,1,20,param1=50,param2=30,minradi$         if circles == none:             print "nonetype"             break         circles = np.uint16(np.around(circles.astype(np.double),3))          in circles[0,:]:             # draw outer circle             cv2.circle(cimg,(i[0],i[1]),i[2],(0,255,0),2)             # draw center of circle             cv2.circle(cimg,(i[0],i[1]),2,(0,0,255),3)          cv2.imwrite('test.jpg',cimg)         out.write(cimg)      if cv2.waitkey(1) & 0xff == ord('q'):         break   cap.release() out.release() cv2.destroyallwindows() 

we working images, video unplayable vlc or other media player.

this image program:

frame in clip

this issue turning playable video now.

thanks in advance.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -