How do I resolve the error "Invalid property: 'Exposure'." when defining webcam properties?

3 views (last 30 days)
How do I resolve this error when I run my script? The commands al work fine when entered directly into the command window however once the script is run I get the following error every time when defining the exposure.
This is the full error message received:
Error using imaqdevice/subsasgn (line 33)
Invalid property: 'Exposure'.
Type 'imaqhelp' for information.
Error in DataCaptureCodev2 (line 32)
vid1.Exposure = -8;
The following code is the relevant code before the 'vid1.Exposure = -8' command:
vid1 = videoinput('winvideo','2','YUY2_640x480');
vid2 = videoinput('winvideo','3','YUY2_640x480');
set(vid1, 'FramesPerTrigger', Inf);
set(vid1, 'ReturnedColorspace', 'rgb');
set(vid2, 'FramesPerTrigger', Inf);
set(vid2, 'ReturnedColorspace', 'rgb');
vid1.FrameGrabInterval = 1;
vid2.FrameGrabInterval = 1;
Any advice will be greatly appreciated, thank you!

Accepted Answer

Walter Roberson
Walter Roberson on 28 Mar 2017
First, it appears to me that Exposure is not directly under the vid* object: you need to getselectedsource() to access it. The documentation https://www.mathworks.com/matlabcentral/answers/92203-why-am-i-unable-to-obtain-any-device-properties-when-creating-video-input-objects-using-the-winvideo implies that the Exposure property will simply not exist there if it is not settable for the device.
You appear to be using Windows. If you are using USB webcams then you could use the USB webcam interface instead, and set properties through it: http://www.mathworks.com/help/supportpkg/usbwebcams/ug/set-properties-for-webcam-acquisition.html
With the two cameras I have attached to my system, there is no property Exposure for either videoinput() or webcam() objects -- but I am using Mac so there just might not be any support for setting the properties.
  2 Comments
Fiona Gartland
Fiona Gartland on 28 Mar 2017
Thank you, the getselectedsource() works for one of the webcams however the other returns an error saying: "No public property Exposure exists for class videosource." The cameras are the same, is there a solution to this error please?
Walter Roberson
Walter Roberson on 28 Mar 2017
If you restart MATLAB does the problem stay with the camera? If you exchange USB ports, does the problem stay with the camera?

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!