#!/usr/bin/env python3

import unittest

from pyboof import gateway
import pyboof as pb
import numpy as np

pb.init_memmap()


class ChecksFactoryFiducialCalibration(unittest.TestCase):
    """
    Test factory function calls to see if they crash.
    """
    def test_chessboardX(self):
        config_detector = pb.ConfigChessboardX()
        config_target = pb.ConfigGridDimen(5, 6, 0.30)

        pb.FactoryFiducialCalibration.chessboardX(config_target,
                                                  config_detector)
        pb.FactoryFiducialCalibration.chessboardX(config_target)

    def test_chessboardB(self):
        config_detector = pb.ConfigChessboardBinary()
        config_target = pb.ConfigGridDimen(5, 6, 0.30)

        pb.FactoryFiducialCalibration.chessboardB(config_target,
                                                  config_detector)
        pb.FactoryFiducialCalibration.chessboardB(config_target)
示例#2
0
# 2、姓名:第二页
# 3、证号:第二页
# 4、准驾车型:必须有A2
# 5、从业资格证类别:
# (1)道路危险货物运输驾驶员
# (2)道路危险货物运输押运人员
# 6、发证机关的有效期限:会有多次记录(可能会翻页),需要识别最后一次:
# (1)2026-01-01

######### QRcode  Extractor would be nice

import os
import numpy as np
import pyboof as pb

pb.init_memmap()  # Optional


class QR_Extractor:
    # Src: github.com/lessthanoptimal/PyBoof/blob/master/examples/qrcode_detect.py
    def __init__(self):
        self.detector = pb.FactoryFiducial(np.uint8).qrcode()

    def extract(self, img_path):
        if not os.path.isfile(img_path):
            print('File not found:', img_path)
            return None
        image = pb.load_single_band(img_path, np.uint8)
        self.detector.detect(image)
        qr_codes = []
        for qr in self.detector.detections:
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")
示例#4
0
#!/usr/bin/env python3

import pyboof as pb
import numpy as np
import os
import cv2
import transforms3d.euler  # pip install transforms3d

pb.init_memmap(5)

data_path = "../data/example/fisheye/theta/"

model_pinhole = pb.CameraPinhole()
model_pinhole.set_image_shape(450, 450)
model_pinhole.set_matrix(250, 250, 0, 300, 300)

model_fisheye = pb.CameraUniversalOmni()
model_fisheye.load(os.path.join(data_path, "front.yaml"))

transform = pb.NarrowToWideFovPtoP(narrow_model=model_pinhole,
                                   wide_model=model_fisheye)

image_fisheye = pb.load_planar(os.path.join(data_path, "front_hike.jpg"),
                               np.uint8)
image_pinhole = image_fisheye.createNew(model_pinhole.width,
                                        model_pinhole.height)

image_distorter = transform.create_image_distort(
    pb.ImageType(image_fisheye.getImageType()))

image_distorter.apply(image_fisheye, image_pinhole)
示例#5
0
import unittest

from pyboof import gateway
import pyboof as pb

pb.init_memmap()

class TestMemMapFunctions(unittest.TestCase):
    def test_convert_list_tuple64(self):
        original = [[1, 2.34, 6.7], [-23.4, 934.123, 56.1]]

        # python to java
        java_list = gateway.jvm.java.util.ArrayList()
        pb.mmap_list_python_to_TupleF64(original, java_list)

        # java to python
        found = []
        pb.mmap_list_TupleF64_to_python(java_list, found)

        self.assertEqual(len(original), len(found))

        for i in xrange(len(original)):
            a = original[i]
            b = found[i]
            self.assertEqual(len(a),len(b))
            for j in xrange(len(a)):
                self.assertEqual(a[j],b[j])

    def test_convert_list_Point2DF64(self):
        original = [(1, 2.34), (-23.4, 934.123)]