How can I adjust the contrast of a live video?
12 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Marc
el 5 de Jun. de 2014
Comentada: Sanjay Yadav
el 20 de En. de 2017
I am using the Image Acquisition Toolbox to create a simple interactive GUI that should allow the user to preview the image and dynamically adjust the contrast of the video feed. I can get it to work in the command line using the following code:
vid = videoinput('winvideo',1);
src = getselectedsource(vid);
preview(vid);
src.Contrast = 200;
This works an allows me to adjust the contrast. For some reason, when I implement this in my GUI, MATLAB does not allow me to set the video input. I am trying this inside the slider function call:
vid = videoinput('winvideo',1);
src = getselectedsource(vid);
con = get(handles.contrast, 'Value');%gets slider value
src.Contrast = con;
When I try this, MATLAB says that I cannot adjust the contrast when the video is running.
"Error using imaqchild/subsasgn (line 34) Contrast: Property can not be set while Running is set to 'on'."
Does anyone have any idea how to get around this issue? It seems like the value can be changed while it's running in the preview window.
Thanks for any help.
1 comentario
Sanjay Yadav
el 20 de En. de 2017
I'm using the same logic but its not working out for me. Can you share your code if you have it yet?
Respuesta aceptada
David Tarkowski
el 13 de Jun. de 2014
There isn't really a good way to get around this. What happens when you set the contrast while the preview is running is that the camera stream is automatically stopped, the contrast is adjusted, and then the stream is then automatically restarted. When the object is running, the toolbox will not automatically stop the stream.
If you want to let the user change the contrast while the acquisition is running, you'll have to manually call stop before setting the contrast, and the call start to restart the object. This will cause any acquired data which has not been returned with getdata to be discarded.
Más respuestas (1)
Image Analyst
el 13 de Jun. de 2014
Editada: Image Analyst
el 13 de Jun. de 2014
Unlike the old analog frame grabbers, with digital cameras you often can't adjust contrast in very flexible ways. For example you can't have an offset (min value) or max value or slope. About the only thing you can do, if the camera adapter allows it, is to set the gamma.
0 comentarios
Ver también
Categorías
Más información sobre National Instruments Frame Grabbers en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!