def h264show(filenames): print cvideo.init() img = np.zeros([720, 1280, 3], dtype=np.uint8) missingIFrame = True pave = PaVE() for filename in filenames: pave.append(open(filename, "rb").read()) header, payload = pave.extract() while len(header) > 0: w, h = frameEncodedWidth(header), frameEncodedHeight(header) if img.shape[0] != h or img.shape[1] != w: print img.shape, (w, h) img = np.zeros([h, w, 3], dtype=np.uint8) missingIFrame = missingIFrame and not isIFrame(header) if not missingIFrame: arr = parseFrame(payload) assert cvideo.frame(img, isIFrame(header) and 1 or 0, payload) if arr: for x, y, mx, my in arr: cv2.line(img, (16 * x + 8, 16 * y + 8), (16 * x + 8 + mx / 4, 16 * y + 8 + my / 4), (0, 0, 255), 1) cv2.imshow('image', img) if cv2.waitKey(1) & 0xFF == ord('q'): break header, payload = pave.extract()
def imageProcess(self,queue): global running cvideo.init() img = numpy.zeros([360, 640, 3], dtype=numpy.uint8) while running: frame = queue.get() if frame == None: break ret = cvideo.frame(img, frame[1], frame[2]) if not ret: continue assert ret self.image_pub.publish(self.bridge.cv2_to_imgmsg(img, "bgr8"))
def processMain( queue ): cvideo.init() img = np.zeros([360,640,3], dtype=np.uint8) while True: frame = queue.get() if frame is None: break sys.stderr.write('.') ret = cvideo.frame( img, frame[1], frame[2] ) assert ret cv2.imshow('image', img) key = cv2.waitKey(1) if key >= 0: break
def processMain(queue): cvideo.init() img = np.zeros([360, 640, 3], dtype=np.uint8) while True: frame = queue.get() if frame is None: break sys.stderr.write('.') ret = cvideo.frame(img, frame[1], frame[2]) assert ret cv2.imshow('image', img) key = cv2.waitKey(1) if key >= 0: break
def wrapper(packet): global g_pave global g_img if g_pave == None: g_pave = PaVE() cvideo.init() g_img = np.zeros([360, 640, 3], dtype=np.uint8) g_pave.append(packet) header, payload = g_pave.extract() while payload: if isIFrame(header): w, h = frameEncodedWidth(header), frameEncodedHeight(header) if g_img.shape[0] != h or g_img.shape[1] != w: print g_img.shape, (w, h) g_img = np.zeros([h, w, 3], dtype=np.uint8) ret = cvideo.frame(g_img, isIFrame(header) and 1 or 0, payload) frame = g_img assert ret if ret: result = processAvoidGreen(frame, debug=False) return (frameNumber(header), timestamp(header)), result header, payload = g_pave.extract()
def wrapper( packet ): global g_pave global g_img if g_pave == None: g_pave = PaVE() cvideo.init() g_img = np.zeros([360,640,3], dtype=np.uint8) g_pave.append( packet ) header,payload = g_pave.extract() while payload: if isIFrame( header ): w,h = frameEncodedWidth(header), frameEncodedHeight(header) if g_img.shape[0] != h or g_img.shape[1] != w: print g_img.shape, (w,h) g_img = np.zeros([h,w,3], dtype=np.uint8) ret = cvideo.frame( g_img, isIFrame(header) and 1 or 0, payload ) frame = g_img assert ret if ret: result = processAvoidGreen( frame, debug=False ) return (frameNumber( header ), timestamp(header)), result header,payload = g_pave.extract()
def h264show( filenames ): print cvideo.init() img = np.zeros([720,1280,3], dtype=np.uint8) missingIFrame = True pave = PaVE() for filename in filenames: pave.append( open( filename, "rb" ).read() ) header,payload = pave.extract() while len(header) > 0: w,h = frameEncodedWidth(header), frameEncodedHeight(header) if img.shape[0] != h or img.shape[1] != w: print img.shape, (w,h) img = np.zeros([h,w,3], dtype=np.uint8) missingIFrame = missingIFrame and not isIFrame(header) if not missingIFrame: arr = parseFrame( payload ) assert cvideo.frame( img, isIFrame(header) and 1 or 0, payload ) if arr: for x,y,mx,my in arr: cv2.line( img, (16*x+8,16*y+8), (16*x+8+mx/4,16*y+8+my/4), (0,0,255), 1 ) cv2.imshow('image', img) if cv2.waitKey(1) & 0xFF == ord('q'): break header,payload = pave.extract()
import cvideo import cv2 import numpy as np import sys sys.path.append( ".." ) from pave import PaVE, isIFrame, frameEncodedWidth, frameEncodedHeight print cvideo.init() img = np.zeros([720,1280,3], dtype=np.uint8) missingIFrame = True filename = sys.argv[1] pave = PaVE() pave.append( open( filename, "rb" ).read() ) header,payload = pave.extract() while len(header) > 0: w,h = frameEncodedWidth(header), frameEncodedHeight(header) if img.shape[0] != h or img.shape[1] != w: print img.shape, (w,h) img = np.zeros([h,w,3], dtype=np.uint8) missingIFrame = missingIFrame and not isIFrame(header) if not missingIFrame: assert cvideo.frame( img, isIFrame(header) and 1 or 0, payload ) cv2.imshow('image', img) if cv2.waitKey(1) & 0xFF == ord('q'): break header,payload = pave.extract()
import cvideo import cv2 import numpy as np import sys sys.path.append("..") from pave import PaVE, isIFrame, frameEncodedWidth, frameEncodedHeight print cvideo.init() img = np.zeros([720, 1280, 3], dtype=np.uint8) missingIFrame = True filename = sys.argv[1] pave = PaVE() pave.append(open(filename, "rb").read()) header, payload = pave.extract() while len(header) > 0: w, h = frameEncodedWidth(header), frameEncodedHeight(header) if img.shape[0] != h or img.shape[1] != w: print img.shape, (w, h) img = np.zeros([h, w, 3], dtype=np.uint8) missingIFrame = missingIFrame and not isIFrame(header) if not missingIFrame: assert cvideo.frame(img, isIFrame(header) and 1 or 0, payload) cv2.imshow('image', img) if cv2.waitKey(1) & 0xFF == ord('q'): break header, payload = pave.extract()