Exemple #1
0
	# On versions of L4T prior to 28.1, add 'flip-method=2' into gst_str
	gst_str = ('nvcamerasrc ! '
			   'video/x-raw(memory:NVMM), '
			   'width=(int)2592, height=(int)1458, '
			   'format=(string)I420, framerate=(fraction)30/1 ! '
			   'nvvidconv ! '
			   'video/x-raw, width=(int){}, height=(int){}, '
			   'format=(string)BGRx ! '
			   'videoconvert ! appsink').format(width, height)
	return cv2.VideoCapture(gst_str, cv2.CAP_GSTREAMER)
'''

reid_mode = cam_reid.reid_model()

# encode origin image
compare = cam_reid.Compare(model=reid_mode, origin_img="./image/origin")
origin_f, origin_name = compare.encode_origin_image()


def open_cam_onboard(width, height):
    gst_elements = str(subprocess.check_output('gst-inspect-1.0'))
    if 'nvcamerasrc' in gst_elements:
        # On versions of L4T prior to 28.1, add 'flip-method=2' into gst_str
        gst_str = ('nvcamerasrc ! '
                   'video/x-raw(memory:NVMM), '
                   'width=(int)2592, height=(int)1458, '
                   'format=(string)I420, framerate=(fraction)30/1 ! '
                   'nvvidconv ! '
                   'video/x-raw, width=(int){}, height=(int){}, '
                   'format=(string)BGRx ! '
                   'videoconvert ! appsink').format(width, height)
Exemple #2
0
from detection import cam_detection
from reid import cam_reid
import cv2
import time

detect_model = cam_detection.detection_model()
reid_mode = cam_reid.reid_model()

# encode origin image
compare = cam_reid.Compare(
    model=reid_mode,
    origin_img="/home/hlzhang/project/detection_reid/image/origin")
origin_f, origin_name = compare.encode_origin_image()


def handle_signal_image(img):

    #    # encode origin image
    #    compare = cam_reid.Compare(model=reid_mode, origin_img=origin_img)
    #    origin_f, origin_name = compare.encode_origin_image()

    # person detection
    img = cv2.resize(img, (640, 480))
    idxs, classes, anchors = cam_detection.detection_person(img, detect_model)

    bounding_boxs = []
    for j in range(idxs[0].shape[0]):
        bbox = anchors[idxs[0][j], :]
        x1 = int(bbox[0])
        y1 = int(bbox[1])
        x2 = int(bbox[2])