Ask Your Question

Dave92F1's profile - activity

2020-08-13 13:01:47 -0600 received badge  Famous Question (source)
2020-07-02 08:18:27 -0600 received badge  Popular Question (source)
2019-05-18 21:48:32 -0600 received badge  Necromancer (source)
2019-05-08 20:03:42 -0600 answered a question How to detect closing of namedWindow by mouse or ALT+F4

In Python, poll with cv2.getWindowImageRect(windowName). It will return (-1, -1, -1, -1) when the user clicks the window

2017-08-01 03:47:17 -0600 received badge  Notable Question (source)
2016-05-29 15:52:22 -0600 received badge  Popular Question (source)
2014-09-22 08:41:36 -0600 received badge  Student (source)
2014-03-27 11:10:23 -0600 asked a question How to control VideoWriter encoding bitrate?

Is there a way to control the video codec encoding bitrate in OpenCV?

With ffmpeg you can do -qscale n. That will (indirectly) influence the bitrate. Is there an equivalent via the OpenCV Python bindings?

The bitrate I get now seems to be around 8 to 10 Mbps, which is really high (quality is excellent of course, but I'm trying to save on bandwidth...)

2014-03-26 19:08:12 -0600 asked a question WaitKey without waiting?

Is there a way to call WaitKey without incurring a (minimum) 1 millisecond block?

Suppose I have a 300 frames/sec camera & display - to display each frame I need to call waitkey(1) 300 times each second (because you have to call waitkey to get imshow to work), which consumes 30% of my entire CPU.

Most of that time is just sitting there waiting for the keyboard, at 1 ms per call.

This seems like a huge waste of CPU time.

Is there some way to call WaitKey without the needless wait-for-keyboard delay?

WaitKey(0.0000000001) I suppose would do it, but WaitKey only takes integers...

2014-03-26 19:00:22 -0600 received badge  Supporter (source)
2014-03-26 18:52:27 -0600 received badge  Editor (source)
2014-03-26 18:50:50 -0600 asked a question Test for camera frame available in Python?

How can I check if a new frame is available from the camera (without waiting for it)?

If I do a cam.grab() it always returns True, even if I just retrieved a frame an instant before. If I then do a cam.retrieve(), that call blocks until the next frame is ready (wasting CPU time that I need for other things).

If I call cam.read(), that also blocks until the next frame is ready from the camera.

How can I check if a frame is ready without waiting for it?

I'd like to do something like this:

while True:
  if cam.newFrameReady()
    frame = cam.read()
    [do something with the frame]

  [do some other stuff while frame is not yet ready]

Is there a way to do this in Python?

FWIW, I'm on Win7 using a DirectShow camera.