フィルターのクリア

VC0706 image reading

2 ビュー (過去 30 日間)
Daniel
Daniel 2016 年 5 月 16 日
編集済み: Walter Roberson 2016 年 5 月 16 日
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 件)

カテゴリ

Help Center および File ExchangeMATLAB Support Package for IP Cameras についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by