Skip to content

Instantly share code, notes, and snippets.

@Williangalvani
Created November 25, 2015 14:32
Show Gist options
  • Save Williangalvani/8d8969cfce9c3d9df73c to your computer and use it in GitHub Desktop.
Save Williangalvani/8d8969cfce9c3d9df73c to your computer and use it in GitHub Desktop.
import cv2
import numpy as np
# Create image 300x300xrgb
height=480
width=640
image = np.zeros((height,width, 3), np.uint8)
fourcc = cv2.cv.CV_FOURCC(*'XVID')
video = cv2.VideoWriter('output.avi',fourcc, 20.0, (640,480))
key=0
# Create circle
r=100;x=width;y=height;
ang=0
while(key!=ord('a') and ang < 1*3.1415):
ang=ang+0.01
xp=r*np.cos(ang);
yp=r*np.sin(ang);
image2=image.copy ();
cv2.circle(image2, (150+int(xp),150+int(yp)), 30,(10,250,250),-1)
video.write(image2)
cv2.imshow('image',image2)
key=cv2.waitKey(1)
print str(ang*10/3.1516) + '%'
print video.isOpened()
video.release()
cv2.destroyAllWindows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment