Black screen in video player

14 views (last 30 days)
Arnaud Tullio
Arnaud Tullio on 1 Sep 2017
Answered: Amit Doshi on 7 Sep 2017
hello, I am trying to track points in real time. The problem is that my camera is 10 bits and the video player displays it in 16bits so the video is black. How can I change that?
The part of my code where I track and display the video is :
% Création de l'objet vidéo
vid=videoinput(handles.ADA,handles.numero,handles.format);
frame=getsnapshot(vid);
videoPlayer = vision.VideoPlayer;
% Création des trackers
pointTracker = vision.PointTracker('MaxBidirectionalError', 3);
% Création des points à tracker (source)
pointTracker2 = vision.PointTracker('MaxBidirectionalError', 3);
initialize(pointTracker,barycentre1,frame);
point(2,:) = barycentre2;
runloop=true;
while runloop
%Définition du point à tracker
point(1,:) = step(pointTracker,frame);
% Inserer physique sur la vidéo un marqueur
out = insertMarker(frame,point,'x');
% Calcule de la distance entre les 2 markers (norme)
Norme=sqrt(abs(((point(2,2) - point(1,2))).^2+abs((point(2,1) - point(1,1))).^2));
% Calcul de la distance en micro et microrad
Dmili=Norme*PixelNum*0.001;
Drad=(Dmili/FocaleNum)*1000;
% Affiche la distance entre les 2 points
set(handles.dist,'String',num2str(Drad));
set(handles.dist2,'String',num2str(Dmili));
% Affichage de la vidéo
step(videoPlayer, out);
end

Accepted Answer

Amit Doshi
Amit Doshi on 7 Sep 2017
This is a common issue since many cameras 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.
To workaround this issue, do the following:
First approach:
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.
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.
Please see the related solutions below for additional troubleshooting information.
Second approach:
Use the following command before ‘preview’ to the allow MATLAB to capture full bitness depth:
>>imaqmex('feature', '-previewFullBitDepth', true);

More Answers (0)

Community Treasure Hunt

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

Start Hunting!