How can I log frames to disk and show a live view from from a 10 bit depth camera?

I have a 10 bit depth camera and I would like to show a live view and log the frames to disk. Is there an example I can use to get started?

 Accepted Answer

The following MATLAB example code enables the full bit depth mode for camera preview and configures disk logging with a format which supports bit depth greater than 8 bit.
%%Example live view and disk logging from 10-bit depth camera
%%Configure camera
% Set preview data to native camera bit depth (default is 8 bit)
imaqmex('feature', '-previewFullBitDepth', true);
v = videoinput('winvideo', 1, 'Y16 _640x480');
%%Configure preview
% Create a preview window and get image and axes handles
im = preview(v);
ax = im.Parent;
% Specify scaled grayscale data mapping to colormap
im.CDataMapping = 'scaled';
% Specify a colormap to display grayscale image mapped to RGB image
colormap(ax, gray(1024));
% Specify auto detection of CData limits
ax.CLimMode = 'auto';
% Or, specify a fixed signal data range to display
% signalRange = [0 2^10-1];
% ax.CLim = signalRange;
%%Configure disk logging
v.LoggingMode = 'disk';
v.DiskLogger = VideoWriter('logfile.mj2', 'Motion JPEG 2000');
%%Start Acquisition
start(v)
pause(30)
stop(v)
while (v.FramesAcquired ~= v.DiskLoggerFrameCount)
pause(0.1)
end
%%Clean up
delete(v)
clear v
 

More Answers (0)

Categories

Find more on MATLAB Support Package for USB Webcams in Help Center and File Exchange

Products

Release

R2017a

Tags

No tags entered yet.

Community Treasure Hunt

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

Start Hunting!