Acquire 16-bit image from usb webcam using support package

I have a USB camera that supports 16-bit image acquisition. The code below creates a 512x640x3 uint8 where all of the layers are identical (as I expect for a gray scale image)
clear
close
webcamlist
cam = webcam(2)
img = snapshot(cam);
figure
imshow(img)

4 commentaires

Do you have a question?
Yes, It would help to have a question if I want an answer. I am trying to get a uint16 out of the camera using the webcam package. Right now I only get a scaled uint8. I have vendor software in Python that can deliver uint16 so I know the camera can support 16 bit. I would prefer a Matlab solution for easier integration. Is there a way to specify 16-bit output?
The snapshot function only returns output as a uint8 (see output data types here).
To acquire other data types, you likely need to use the Image Acquistion Toolbox. I also had to install the Image Acquisition Toolbox Support Package for OS Generic Video Interface in order capture images. Unfortunatly, my camera does not provide the data at uint16, so I can't test that.
Here's the code I used.
% determine what type of video input I have
obj = imaqhwinfo
% Capture a single frame.
vidobj = videoinput('winvideo',2)
frame = getsnapshot(vidobj);
I had been looking for things earlier, and I did see this:
I don't have IAT or a webcam, so I'm gonna have to tap out.
Er, well now you've got me wondering if I can access my analog capture card in anything other than uint8. I'm just going to assume the answer is no.

Connectez-vous pour commenter.

Réponses (0)

Question posée :

le 11 Mar 2025

Commenté :

DGM
le 11 Mar 2025

Community Treasure Hunt

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

Start Hunting!

Translated by