Exemple #1
0
#p = sp.Popen('/usr/local/bin/ffmpeg -f image2pipe -r 1/2 -s 240x960 -vcodec mjpeg http://localhost:8090/cam2.ffm', shell=True, stdin=PIPE)
#sp.call('/usr/local/bin/ffmpeg -f image2 -s 240x960 -r 1 -i frame.png -vcodec mjpeg http://localhost:8090/cam2.ffm', shell=True)

# cmdline = ['vlc', '--demux', 'h264', '-'] #pick a media player
# cmdline = ['mplayer', '-fps', '25', '-cache', '1024', '-']
#player = subprocess.Popen(cmdlin, stdin=sp.PIPE)

while (cap.isOpened()):  #-f image2pipe
    command = '/usr/local/bin/ffmpeg -f image2 -i - c-s 240x960 -pix_fmt bgr24 -r 1 -c:v mjpeg  http://localhost:8090/cam2.ffm'
    player = sp.Popen(command, stdin=sp.PIPE, bufsize=10**8, shell=True)

    ret, frame = cap.read()  #print(type(frame), frame.dtype)

    start = time.time()

    pano = fish2pano(frame)  #.astype('u8')

    #    print(pano.shape, pano.dtype)       # (240, 960, 3)
    #    out.write(pano)

    #    ret, jpeg = cv2.imencode('.jpg', pano)
    #    pano = jpeg.tobytes()
    #    sp.call('/usr/local/bin/ffmpeg -f image2 -r 1 -i pano.jpg http://localhost:8090/cam2.ffm', shell=True)

    #    cv2.imwrite(os.getcwd()+'/fisheye/frame.png' % count, pano)
    #    count +=1

    #   p.stdout.write(frame.tostring())
    #    cv2.imwrite('frame.png', pano)
    #    sp.call('/usr/local/bin/ffmpeg -f image2 -s 240x960 -r 1 -i frame.png -vcodec mjpeg http://localhost:8090/cam2.ffm', shell=True)
Exemple #2
0
cap0 = cv2.VideoCapture(0)
cap0.set(3, 640)
cap0.set(4, 480)  # this give 160x120 images

cap1 = cv2.VideoCapture(1)
cap1.set(3, 640)
cap1.set(4, 480)  # this give 160x120 images

while (cap0.isOpened() & cap1.isOpened()):
    ret0, frame0 = cap0.read()
    ret1, frame1 = cap1.read()

    if (ret0 == True & ret1 == True):
        start = time.time()

        pano0 = fish2pano(frame0)  #.astype('u8')
        pano1 = fish2pano(frame1)  #.astype('u8')

        stack = np.vstack((pano0, pano1))
        out.write(stack)
        #out0.write(pano0)
        #out1.write(pano1)

        #cv2.imwrite('frame1.png', pano0)# % count, pano)
        #    cv2.imwrite()
        # sp.call('/usr/local')
        #    sp.call('/usr/local/bin/ffmpeg -f image2 -s 240x960 -r 1/5 -i frame.png -vcodec mjpeg http://localhost:8090/cam2.ffm', shell=True)
        #pipe.proc.stdout.write(frame.tostring() )

        #        cv2.imshow('frame',frame)
        end = time.time()