Merge branch 'master' of git.xpub.nl:/var/www/git.xpub.nl/repos/tgc3

master
ugrnm 7 years ago
commit 8f1a9af83b

@ -57,37 +57,32 @@ def send_flow0(img, flow, step=4): # size grid
# client.send_message("/franc", m)
flines = np.int32(flines)
cv2.polylines(vis, flines, 0, (0, 40, 255)) # BGR
for (x1, y1), (x2, y2) in flines:
cv2.circle(vis, (x1, y1), 1, (0, 255, 0), -1)
return vis
flines = np.int32(flines)
cv2.polylines(vis, flines, 0, (0, 40, 255)) # BGR
for (x1, y1), (x2, y2) in flines:
cv2.circle(vis, (x1, y1), 1, (0, 255, 0), -1)
return vis
# flines = np.int32(flines)
# cv2.polylines(vis, flines, 0, (0, 40, 255)) # BGR
# for (x1, y1), (x2, y2) in flines:
# cv2.circle(vis, (x1, y1), 1, (0, 255, 0), -1)
# return vis
# flines = np.int32(flines)
# cv2.polylines(vis, flines, 0, (0, 40, 255)) # BGR
# for (x1, y1), (x2, y2) in flines:
# cv2.circle(vis, (x1, y1), 1, (0, 255, 0), -1)
# return vis
# cv2.rectangle(img, pt1, pt2, color[, thickness[, lineType[, shift]]])
if __name__ == '__main__':
import sys
print help_message
try: fn = sys.argv[1]
except: fn = 0
#data="hello"
# client = udp_client.SimpleUDPClient("127.0.0.1", 9001)
# connect camera
# cam = video.create_capture("0:size=160x120") #canvas size in pixels
cam = PiCamera()
framesize = (160, 120)
camera.resolution = framesize
camera.framerate = 32
rawCapture = PiRGBArray(camera, size=framesize)
framesize = (160, 128)
cam.resolution = framesize
cam.framerate = 32
rawCapture = PiRGBArray(cam, size=framesize)
# allow the camera to warmup
time.sleep(0.25)
@ -97,18 +92,20 @@ if __name__ == '__main__':
client.connect(('127.0.0.1', 9001)) # first argument is the IP of the host, second argument is the port to use
prevgray = None
for frame in camera.capture_continuous(rawCapture, format="bgr", use_video_port=True):
for frame in cam.capture_continuous(rawCapture, format="bgr", use_video_port=True):
# while True:
# print "GRAB FRAME"
img = frame.array
# ret, img = cam.read()
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
flow = cv2.calcOpticalFlowFarneback(prevgray, gray, 0.5, 3, 15, 3, 5, 1.2, 0)
if prevgray != None:
flow = cv2.calcOpticalFlowFarneback(prevgray, gray, 0.5, 3, 15, 3, 5, 1.2, 0)
send_flow0(gray, flow)
prevgray = gray
# clear the stream in preparation for the next frame
rawCapture.truncate(0)
# cv2.imshow('flow', send_flow0(gray, flow))
# cv2.imshow('flow', )
#ch = 0xFF & cv2.waitKey(5)
#if ch == 27:

Loading…
Cancel
Save