Why do I receive a black preview window with videoinput preview?

9 views (last 30 days)
I am using a Hamamatsu C8484-05C camera with the Image Acquisition Toolbox. I have created a VIDEOINPUT object by making use of the Hamamatsu adaptor as follows:
vid = videoinput('hamamatsu',1)
However, when I try to preview the video feed from my camera using the PREVIEW functionality:
preview(vid)
The preview window opens but all I see is a black image.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 14 Feb 2020
Edited: MathWorks Support Team on 14 Feb 2020
This is a common issue since many cameras (including the Hamamatsu C8484-05C) do not return 16-bit data and so they do not send a frame that spans the full range of a 16-bit frame.
For example, if the camera's sensor is 12-bit, the frame data in a 16-bit mode can range as high as 2^16-1=65535 but the camera will only return 12-bit data which will be limited to 2^12-1=4095. Therefore, the maximum pixel value from the camera is 4095. However, the maximum value for the data type is 65535 and so the pixels appear black or dark blue.
If using MATLAB R2008b or later, a possible workaround is to use the following command before creating the videoinput object:
imaqmex('feature', '-previewFullBitDepth', true);
You can also configure the preview axes CDataMapping and CLim properties.
vid = videoinput('hamamatsu', 1);
h = preview(vid);
a = ancestor(h, 'axes');
set(h, 'CDataMapping', 'scaled');
% Modify the following numbers to reflect the actual limits of the data
returned by the camera.
% For example the limit for 12-bit camera would be [0 4095].
set(a, 'CLim', [0 4095]);
Other approaches: * To preview the input from the camera, use the IMAQMONTAGE function. This function takes a snapshot of the video feed and displays the image in a MATLAB figure window. For example:
imaqmontage(vid)
  • After the videoinput object has been started and the GETDATA function has been used to move the data into the MATLAB workspace, scale the data (based on the bit depth of the camera). The resulting images should no longer look dark. You can lookup the bit depth of the camera in the camera manual or on the manufacturers web site. For example, to look up the bit-depth for the Hamamatsu camera in question, please refer to the following online resource:
A large number of cameras return 8, 10 or 12-bit mono data. In 8-bit mode the images returned would span the full range (the frame would consist of UINT8 data), however, 10-bit or 12-bit images would need to be scaled appropriately.

More Answers (0)

Products


Release

R2008a

Community Treasure Hunt

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

Start Hunting!