Skip to content

Replace matplotlib with much faster OpenCV 3.2 in the show_frame func…#5

Open
Greendogo wants to merge 1 commit intotorrvision:masterfrom
Greendogo:master
Open

Replace matplotlib with much faster OpenCV 3.2 in the show_frame func…#5
Greendogo wants to merge 1 commit intotorrvision:masterfrom
Greendogo:master

Conversation

@Greendogo
Copy link

…tion.

Fixes Issue #4

I went from ~6fps to ~30fps on my machine.

This still requires changes to the "requirements.txt" file and a python module with OpenCV compiled to use imshow and waitKey must be required (currently the popular but unofficial opencv-python module does not implement them).

Since show_frame no longer uses matplotlib and show_crops and show_scores don't look like they're used at all (didn't check everywhere) it looks like the requirement for matplotlib could be removed along with the references to it in visualization.py and tracker.py (in the imports in that file, and on line 135).

@jvlmdr
Copy link
Collaborator

jvlmdr commented Jun 22, 2017

Thanks!

I think it is OK to introduce a dependency on OpenCV. This may also be useful if we want to do e.g. a live demo using a webcam.

@Greendogo
Copy link
Author

If I wanted to do a live demo using a webcam (provided I already have a groundtruth for my first frame) with the siamese fc tracker, does anyone have any suggestions regarding where to start?

@Greendogo
Copy link
Author

My plan is to attempt to divide Siamfc-tf 's current "tracker" function into three which would be used like so:

tracker = createSiam(params1)
tracker.init(initial_frame, pos_x, pos_y, w, h)
while True:
  frame = camera.read()
  bbox = tracker.update(frame)
  ~<put bbox on frame>~
  cv2.imshow("Siamese Tracker", frame)
  cv2.waitKey(1)

Any advice on parameters or moving things around in the "tracker" function would be most appreciated!

plt.pause(0.001)
plt.clf()
#Adjust Color Channels of frame
frame_adjusted = np.ndarray(shape=(720,1280,3), dtype=np.dtype(np.uint8))
Copy link

@hayatibis hayatibis Aug 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this line should be

frame_adjusted = np.ndarray(shape=np.shape(frame), dtype=np.dtype(np.uint8))

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

Successfully merging this pull request may close these issues.

3 participants