VC0706 image reading
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello All,
I am trying to connect to a vc0706 camera through a usb com port.
Currently I got the following code (found on the internet) , but I can't seem to find the way to read the jpg image from the camera (I am getting a string rather than an image).
Anyone got ideas?
s=serial('com12','baudrate',38400);
set(s,'timeout',10);
%Open serial port
fopen(s);
%Stop FBUFFER
protocolsign=hex2dec('56');
serialnumber=hex2dec('00');
command=hex2dec('36');
datalength=hex2dec('01');
data=hex2dec('00');
fwrite(s,protocolsign,'uint8');
fwrite(s,serialnumber,'uint8');
fwrite(s,command,'uint8');
fwrite(s,datalength,'uint8');
fwrite(s,data,'uint8');
%arret=fread(s,5)
%Get Fbuffer_Length
protocolsign=hex2dec('56');
serialnumber=hex2dec('00');
command=hex2dec('34');
%datalength=hex2dec('00');
datalength=hex2dec('01');%
data=hex2dec('00');%
fwrite(s,protocolsign,'uint8');
fwrite(s,serialnumber,'uint8');
fwrite(s,command,'uint8');
fwrite(s,datalength,'uint8');
fwrite(s,data,'uint8');%
taille = fread(s,9);
newtaille=hex2dec(dec2hex(256*taille(8)+taille(9)))+100;
%Close serial port
fclose(s);
%Adjust Input buffer size to that of the image
set(s,'inputbuffersize',newtaille);
%Reopen Serial port
fopen(s);
%Read FBUF
protocolsign=hex2dec('56');
serialnumber=hex2dec('00');
command=hex2dec('32');
datalength=hex2dec('0c');
data=hex2dec([ '00' ; '0a'; '00'; '00'; '00'; '00'; '00'; '00'; dec2hex(taille(8)); '00' ; 'ff' ;'ff']);
%data=hex2dec([ '00' ; '0a'; '00'; '00'; dec2hex(taille(8)); dec2hex(taille(8)); '00'; '00'; '00'; '00'; '00' ;'0a']);%
fwrite(s,protocolsign,'uint8');
fwrite(s,serialnumber,'uint8');
fwrite(s,command,'uint8');
fwrite(s,datalength,'uint8');
fwrite(s,data,'uint8');
B=fread(s,5); %getting response from camera
if B(4)==0 % If status byte is "0"="success"'yeah' %be happy :)
C=fread(s); %read data
end
%Resume FBUFFER
protocolsign=hex2dec('56');
serialnumber=hex2dec('00');
command=hex2dec('36');
datalength=hex2dec('01');
data=hex2dec('02');
fwrite(s,protocolsign,'uint8');
fwrite(s,serialnumber,'uint8');
fwrite(s,command,'uint8');
fwrite(s,datalength,'uint8');
fwrite(s,data,'uint8');
fread(s,5)
%Close serial port
fclose(s);
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu MATLAB Support Package for IP Cameras finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!