7
$\begingroup$

I work on image processing using images from webcams. It's connected via USB and I get "live" images by:

Dynamic[Refresh[CurrentImage[], UpdateInterval->5]]

but the UpdateInterval option doesn't affect the frequency of image updating. How to make Dynamic get images from webcams with a specific time interval? There is ImageCapture function with a FrameRate option and it works fine, but functionality of ImageCapturelooks excessive for me (I only need an image).

$\endgroup$
  • $\begingroup$ Related conversation in site's chat. $\endgroup$ – Silvia Nov 28 '19 at 17:21
  • $\begingroup$ This appears to happen because CurrentImage has its own internal Refresh to allow for Dynamic[CurrentImage[]] shorthand. The discussion in chat linked above has a workable solution that I have now used in production (ie, an art exhibition) $\endgroup$ – Carl Lange Nov 28 '19 at 18:14
3
$\begingroup$

The easiest way to solve this is by setting the framerate on the device.

dev = First@FindDevices["Camera"]

DeviceConfigure[dev, "FrameRate" -> 1/5]

Dynamic[CurrentImage[]]
$\endgroup$
2
$\begingroup$

Just came across the same problem in my code. Here is a workaround:

capt[dt_] := Block[{},
  Pause[dt];
  CurrentImage[]
  ]


Dynamic[capt[.1]]

Unfortunately, the drawback is that for large sleep times (>0.5seconds) it really slows down the Mathematica notebook (I think it's a side effect of Pause)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.