Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to run it with my own video #1

Open
KyGao opened this issue Apr 26, 2020 · 0 comments
Open

How to run it with my own video #1

KyGao opened this issue Apr 26, 2020 · 0 comments

Comments

@KyGao
Copy link

KyGao commented Apr 26, 2020

Hello, I am new to visual tracking. Your code is the clearest implementation I have found. I tried to add my PC camera to track, but it seems that the bounding box is not able to move. I pastes my test code here. Thanks a lot if someone would help me!

import csk
import numpy as np
from scipy.misc import imread, imsave
import cv2 # (Optional) OpenCV for drawing bounding boxes

length = 14 # sequence length

# 1st frame's groundtruth information
x1 = 325 # position x of the top-left corner of bounding box
y1 = 162 # position y of the top-left corner of bounding box
width = 74 # the width of bounding box
height = 80 # the height of bounding box

sequence_path = "data/" # your sequence path
save_path = "save/" # your save path

tracker = csk.CSK() # CSK instance

cap=cv2.VideoCapture(0)
flag = True

while True:
    ret, img=cap.read()
    frame = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    
    if flag:
        tracker.init(frame,x1,y1,width,height) # initialize CSK tracker with GT bounding box
        flag = False
        cv2.rectangle(img, (x1, y1), (x1+width, y1+height), (0,255,0), 2)
        cv2.imshow("original", img)
    else:
        x1, y1 = tracker.update(frame) # update CSK tracker and output estimated position
        cv2.rectangle(img, (x1, y1), (x1+width, y1+height), (0,255,0), 2)
        cv2.imshow("frame", img)
    
    k=cv2.waitKey(30) & 0xFF
    if k==32:
        break

# clean up the camera and close any open windows
cap.release()
cv2.destroyAllWindows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant