Beispiel #1
0
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()
Beispiel #2
0
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()
Beispiel #3
0
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()

Beispiel #4
0
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()