Capturing images from a usb webcam without using Ni_Vision package (Ni_Imaq, Ni_ImaqDx, Ni_Imaq I/O). The code is based on Windows SDK functions.
The file 'lrvcam.c' (written in C under LabWindows cvi) enables the capture of images coming from a webcam connected to an usb port. It is provided as an example. Here the program records images with a predefined periodicity such enabling to survey a process (chemical for instance).
Improvement of the code (may 16th 2014): In order to avoid recording redundant images, a threshold (between 0 and 100) is used to decide whether two images are different or not. The threshold can be adjusted by the user according to the lightness and the kinetics of what he observes.
A typical ini file 'lrvcam.ini' and the user interface 'lrvcam.uir' are provided as well.
You can refer to:
for further information.
NOTE : if the device list remains void, check if the cam driver is properly installed.
Software
LabWindows CVI + Windows SDK + Drivers of usb webcam(s).
Do not forget to link to vfw32 and gdi32 sdk libraries (in C:\program files\national instruments\cviXX\sdk\lib\msvc, for instance).
Hardware
usb webcam(s) connected to usb port(s).
Additional Images or Video
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
Hi,
still lrvcam.h is missing. Can you provide it?
not working on windows 8, CVI2013, do you know why?
AlePan,
I have'nt try lrvcam under Windows8.
Suggestion: check for the usbcam driver and the sdk version.
Cheking that and coming back asap
AlePan,
The code has been updated (May 18th, 2015).
How can I put the preview video into a canvas or any other cvi gui objects? I dont want to have a popup preview window and I want to draw something over the preview. Is there any solution for it?
I did'nt perform what you plan to do but I suggest you study the following cvi functions :
- RegisterWinMsgCallback
- GetCVIWindowHandle
you should also write a callback to copy the images coming from the camera to your own canvas.
Thanks, I got help from the community:
Get the handle from the mainpanel and put it into the CreateCaptureWindow function!!!
HANDLE handle;
GetPanelAttribute (panelHandle, ATTR_SYSTEM_WINDOW_HANDLE, &handle);
What is tagfile.h and where can I find it?
I cannot find it on the NI site because I do not have permission.