Ejemplo n.º 1
0
config_tracker.klt.templateRadius = 5
# TODO use SURF tracker for this example as it will be more stable

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)
Ejemplo n.º 2
0
qrResult = ''
pb.init_memmap()
detector = pb.FactoryFiducial(np.uint8).qrcode()

print('Demo will work')
cnt = 0

while (cap.isOpened()):
    ret, frame = cap.read()
    if ret == True:
        # frame = cv2.flip(frame,-1)

        # # QR Code Detector
        # if not findQR:
        frame_mono = cv2.cvtColor(np.uint8(frame), cv2.COLOR_BGR2GRAY)
        boof_img = pb.ndarray_to_boof(frame_mono)
        # boof_img = pb.load_single_band( 'path to image', np.uint8)
        start = time.time_ns()
        detector.detect(boof_img)
        if len(detector.detections) > 0:
            end = time.time_ns()
            print("running time is ", str(end - start))
            print("find QR Code ")
            findQR = True

            qrResult = detector.detections[0].message
            # print("QR Code  is: {}".format(qrResult))

            mask = detector.detections[0].mask_pattern
            # print("mask", mask)
Ejemplo n.º 3
0
import numpy as np

import cv2
import pyboof as pb

# Enable use of memory mapped files for MUCH faster conversion of images between java and python
pb.init_memmap(5)

image_path = '../data/example/outdoors01.jpg'

# Can load an image using OpenCV then convert it into BoofCV
ndarray_img = cv2.imread(image_path, 0)

boof_cv = pb.ndarray_to_boof(ndarray_img)

# Can also use BoofCV to load the image directly
boof_gray = pb.load_single_band(image_path, np.uint8)
boof_color = pb.load_planar(image_path, np.uint8)

# Let's display all 3 of them in Java
# display the results in a single window as a list
image_list = [(boof_cv, "OpenCV"), (boof_gray, "Gray Scale"),
              (boof_color, "Color")]

pb.swing.show_list(image_list, title="Images")

input("Press any key to exit")
import numpy as np

import cv2
import pyboof as pb

# Enable use of memory mapped files for MUCH faster conversion of images between java and python
pb.init_memmap(5)

image_path = '../data/example/outdoors01.jpg'

# Can load an image using OpenCV then convert it into BoofCV
ndarray_img = cv2.imread(image_path,0)

boof_cv = pb.ndarray_to_boof(ndarray_img)

# Can also use BoofCV to load the image directly
boof_gray = pb.load_single_band(image_path,np.uint8)
boof_color = pb.load_planar(image_path,np.uint8)

# Let's display all 3 of them in Java
# display the results in a single window as a list
image_list = [(boof_cv,"OpenCV"),
              (boof_gray,"Gray Scale"),
              (boof_color,"Color")]

pb.swing.show_list(image_list,title="Images")

raw_input("Press any key to exit")
Ejemplo n.º 5
0
# tracker = pb.FactoryTrackerObjectQuad(np.uint8).tld(pb.ConfigTld(False))

# initialize data structures
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: