Example #1
0
video_mosaic = pb.FactoryVideoMosaic(np.uint8).mosaic(config_tracker)

video_mosaic.configure(1000, 500, scale=0.5)

image_input = video_mosaic.get_image_type().create_boof_image(0, 0)

boof_color = None
while True:
    # Capture sequence frame-by-frame
    ret, frame = cap.read()

    # Convert it into a boofcv image
    boof_color = pb.ndarray_to_boof(frame, boof_color)
    # Convert it into the image type required by the tracker
    pb.convert_boof_image(boof_color, image_input)

    # Track the point objects
    time0 = time.time() * 1000.0
    if not video_mosaic.process(image_input):
        print("mosaic failed!")
        video_mosaic.reset()
        continue
    time1 = time.time() * 1000.0

    # Get the mosaic image and display the results
    boof_mosaic = video_mosaic.get_stitched_image()
    ndarray_mosaic = pb.boof_to_ndarray(boof_mosaic)

    cv2.imshow("Video Mosaic", ndarray_mosaic)
ret, frame = cap.read()
if not ret:
    print "Failed to read frame"
    exit(-1)
image_input = tracker.getImageType().create_boof_image(frame.shape[1], frame.shape[0])

while True:
    # Capture frame-by-frame
    ret, frame = cap.read()

    time0 = int(round(time.time() * 1000))
    # Convert it into a boofcv image
    boof_color = pb.ndarray_to_boof(frame)
    time1 = int(round(time.time() * 1000))
    # Convert it into the image type required by the tracker
    pb.convert_boof_image(boof_color,image_input)
    time2 = int(round(time.time() * 1000))

    print("time py to boof: "+str(time1-time0)+" boof to boof "+str(time2-time1))

    if state == 1:
        cv2.rectangle(frame, refPt[0], refPt[1], (0, 255, 0), 2)
    elif state == 2:
        pts_to_quad()
        if not tracker.initialize(image_input,quad):
            print "Initialization failed!"
            state = 0
        else:
            print "Success"
            state = 3
    elif state == 3: