Exemplo n.º 1
0
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()
Exemplo n.º 2
0
 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"))
Exemplo n.º 3
0
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
Exemplo n.º 4
0
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
Exemplo n.º 5
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()
Exemplo n.º 6
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()
Exemplo n.º 7
0
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()
Exemplo n.º 8
0
Arquivo: test.py Projeto: Vibri/heidi
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()

Exemplo n.º 9
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()