yeephycho / tensorflow-face-detection

A mobilenet SSD based face detector, powered by tensorflow object detection api, trained by WIDERFACE dataset.
Apache License 2.0
768 stars 264 forks source link

Can't (?) show frames #5

Closed mirceaciu closed 6 years ago

mirceaciu commented 6 years ago

The output video for me is blank.

If I do cv2.imshow("face", image) it won't show any windows. If i do cv2.imwrite("frames/%s.jpg" % time.time(), image) i can see that frames are being processed, inference time cost is ~0.42.

Tested on Ubuntu 16 machine with no GPU. Is GPU a requirement?

yeephycho commented 6 years ago

Hi there, A GPU is not a must as long as you can run tensorflow framework. This project read a video file and output a video file, please refer to the code for detail and you can change by your will to support the camera application etc.

With regards!

mirceaciu commented 6 years ago

the output video is blank

z362194037 commented 6 years ago

@mirceaciu do you solve this problem? I meet this too

johanna-codes commented 6 years ago

@mirceaciu, @z362194037: I can't explain why, but in my case It worked well only when input video is in mp4 format and output video in avi format. Hope it can help you.

z362194037 commented 6 years ago

@johanna-codes which opencv version do you use?

mirceaciu commented 6 years ago

I did use .mp4 as input and .avi as output.Compiled OpenCv version is 3.2.0

johanna-codes commented 6 years ago

@z362194037 I'm using OpenCV version 3.1.0

z362194037 commented 6 years ago

@mirceaciu change the dimension to your .mp4 file in tensorflow-face-detection.py line46 get work

mirceaciu commented 6 years ago

Setting the output video dimensions same as the camera's input solves the output write problem.

Would be nice to make it work with cv2.imwrite, but i guess this runs in some kind of multi thread so this might not be possible.

kaisark commented 5 years ago

@mirceaciu @yeephycho If you are using opencv (built with fmpeg) to write video output, you need to pay attention to the following:

  1. output video frame is same dimensions (w,h) as input video frame
  2. Your system supports the codec (e.g. XVID, MJPG) you are using
  3. frame rate of output matches input frame rate or processing frame rate (for decent results)
  4. The file name extension (e.g. avi, mp4) of the output must be supported by ffmpeg and the system. AVI seems to work out of the box on Ubuntu systems.

    if out is None: [h, w] = image.shape[:2] fps=8 fourcc = cv2.VideoWriter_fourcc(*'XVID') out = cv2.VideoWriter('./media/test_out.avi', fourcc, fps, (w, h))

fd-tf-mask-computervision gif-downsized_large