Programming Image acquisition with National Instruments in Matlab
3 views (last 30 days)
Show older comments
I have a National Instruments card PCIe-1433 Frame Grabber Device connected via serial port to my laptop. I also have a bus expander that grabs the frames and sends them to my laptop. I am running the Matlab version R2018a with the image acquisition toolbox installed. Currently I am trying to communicate with the National Instruments card to grab and read data as well as change things like integration time or framerate. However, everywhere I look online I can only find functions that work in Labview. Unfortunately, I don't have Labview and would like to use my awesome free Matlab. Any suggestions for where to look or what functions to use would be amazing, as I am running out of time to communicate with this device. Below I have written the code I am using to generate files with the lie video beign generated. Anything can help, thank you!
Pattern = num2str(input('Which Test Pattern? Select 1 through 4: '));
NumFrames = input('Amount of Frames to save: ');
SaveFileName = input('File Name to save to: ' , 's');
ROI = input('Region of Interest [XOffset, YOffset, Width, Height]: ');
dataDir = 'C:\Users\Brandywine\Documents\RushmoreData\';
nDir = [dataDir getTimeStamp '\'];
mkdir(nDir)
FileName = [nDir SaveFileName];
sr = 'tp ';
Test = [sr, Pattern];
ser = serial('com3', 'BaudRate', 115200, 'Terminator', 'CR/LF', 'Timeout', 0.5);
vid = videoinput('ni',1,'Img0');
src = getselectedsource(vid);
if exist('ROI','var') % If the variable ROI was specified as an input
CurROI = vid.ROIPosition; % Specify Region of Interest (ROI) window
vid.ROIPosition = [max(0,ROI(1)),max(0,ROI(2)),min(ROI(3),CurROI(3)),min(ROI(4),CurROI(4))]; % Sets the max ROI dimensions for the Region of Interest window
end
vid.FramesPerTrigger = NumFrames;
fopen(ser);
fprintf(ser,Test);fprintf(ser,'go 1000'); char(fread(ser,100))
preview(vid);
start(vid);
stoppreview(vid);
ImagePattern = getdata(vid);
save(FileName,'SaveFileName');
stop(vid);
fclose(ser);
0 Comments
Answers (0)
See Also
Categories
Find more on National Instruments Frame Grabbers in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!