Ejemplo n.º 1
0
    while True:
        # cv2.imshow('1', pro.image8)
        # cv2.waitKey(0)
        frame = cam.run()
        frame = cv2.flip(frame, 0)
        # pro.addimage(frame)
        # Start timer
        timer = cv2.getTickCount()
        # Update tracker
        ok, bbox = tracker.update(frame)
        # Cakculate FPS
        fps = cv2.getTickFrequency() / (cv2.getTickCount() - timer)
        # Draw bonding box
        # 前两个参数调大小,后两个参数调位置,第五个参数调框的宽度
        pro.changeimage(550, 400, 245, 190, 5)
        if ok:
            p1 = (int(bbox[0]), int(bbox[1]))
            p2 = (int(bbox[0] + bbox[2]), int(bbox[1] + bbox[3]))
            # cv2.rectangle(frame, p1, p2, (255, 0, 0), 2, 1)
        else:
            cv2.putText(frame, "Tracking failed detected", (100, 80),
                        cv2.FONT_HERSHEY_SIMPLEX, 0.75, (0, 0, 255), 2)
        # 展示tracker类型
        cv2.putText(frame, tracker_type + "Tracker", (100, 20),
                    cv2.FONT_HERSHEY_SIMPLEX, 0.75, (50, 170, 50), 2)
        # 展示FPS
        cv2.putText(frame, "FPS:" + str(fps), (100, 50),
                    cv2.FONT_HERSHEY_SIMPLEX, 0.75, (50, 170, 50), 2)
        # Result
        # cv2.imshow("Tracking", frame)
Ejemplo n.º 2
0
# 前两个参数是一屏二屏标记的颜色,第三个参数是标记的宽度,如果想要二屏标记也是绿色就把(255,255,255)改成(0,255,0)
pro.bindingwi((0, 255, 0), (255, 255, 255), 3)
pro.nobiaotilan()
# 假设两个参数m,n.  n是为了计数 m是相机拍到的几张图混合在一起
n, m = 0, 4
# 不开相机的时候,拿这个图当相机的图
frame = cv2.imread(r'D:\navagation\time\piuture\IMG_3606.jpg')
frame = cv2.resize(frame, (800, 600))
while 1:
    # frame = np.zeros([800, 1280, 3], np.uint8)
    n = n + 1
    # frame = Img.enhancebri(m)
    if n % m == 0:
        n = 0
        # 给一屏幕中间加个十字线 299:300 399:400
        frame[297:302, 0:799] = [0, 255, 0]
        frame[0:599, 397:402] = [0, 255, 0]
        pro.addimage(frame)
        # 前两个参数调大小,后两个参数调位置,第五个参数调框的宽度
        pro.changeimage(500, 200, 10, 30, 5)
        pro.showimage()
    print('n', n)
    k = cv2.waitKey(1) & 0xFF
    if k == ord('m'):
        pro.mode = not pro.mode
    # if k == ord('q'):
    # 关闭相机
    # break
    # Img.closecamera()
    # cv2.destroyAllWindows()