Register Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
kms

Member
Registered:
Posts: 37
Reply with quote  #1 
Hi Jaewon,

I was hoping to video record the subject's movements while running my task in ML. To get video frame timestamps with respect to trial events, I wrote a line of code in my existing task file to trigger the video recording (connected via USB) at the beginning of each trial and another line to stop it at the end of it. 

Though the camera doesn't physically open a preview window, I get an error:

"Multiple image acquisition objects cannot access the same device simultaneously."

Is there a way to circumvent this error? Thanks.


0
Jaewon

Administrator
Registered:
Posts: 547
Reply with quote  #2 
Since I don't know anything about how this video camera works, you need to tell me much more!

Does the camera have a model number? Is it installed on a different computer? How do you trigger the recording? What is the preview window? Does the camera have its own control software?
0
kms

Member
Registered:
Posts: 37
Reply with quote  #3 
Sorry about that! I am using this camera (https://www.theimagingsource.com/products/industrial-cameras/usb-3.0-monochrome/dmk23u618/) connected via a USB to the computer running ML.

The camera is recognized by the image acquisition toolbox of MATLAB via this driver (https://www.theimagingsource.com/support/downloads-for-windows/extensions/icmatlabr2013b/). 

Stand-alone I am able to use the camera (start and stop acquiring/ saving frames) using the toolbox as well as a script [see below]. 'Preview' is a like a figure window which shows what the camera is capturing. It can be optionally turned off, and the images will still get recorded/ logged. 

% MATLAB code for acquiring image data from the camera 

vid = videoinput('tisimaq_r2013_64', 1, 'Y16 (640x480)');

triggerconfig(vid, 'Manual')
vid.LoggingMode = 'disk&memory';
vid.FramesPerTrigger = Inf;

diskLogger = VideoWriter(path, 'Grayscale AVI');
vid.DiskLogger = diskLogger;

% preview(vid);
start(vid); % image acquisition on
trigger(vid) % logging on
% stoppreview(vid);
stop(vid);

In ML, as a starting point, I was trying to record and save frames for every trial separately [may be there is a more efficient way to do it?]. So, I was 'triggering' it ON the first thing in the task code file and 'stopping video' as the last thing in the trial. But it gave the following error somewhere after initializing the video object (presumably after some resource sharing problem with ML?): 

"Multiple image acquisition objects cannot access the same device simultaneously

Thanks.
0
Jaewon

Administrator
Registered:
Posts: 547
Reply with quote  #4 
Thanks for the information.

I don't know what technology the Image Acquisition Toolbox uses, but I don't think it is a conflict with ML. ML certainly do not try to access the camera.

In the code, you create a videoinput object, but I don't see it destroyed. If the toolbox doesn't sever the connection with the camera automatically, a new videoinput object created next time will try to access the same camera and that may be the cause of the problem.

Try putting delete(imaqfind); before the first line or after the last line (or do both). Unfortunately I don't have the toolbox, so I can't test it myself.
0
kms

Member
Registered:
Posts: 37
Reply with quote  #5 
Hi Jaewon,

Answering your query about 'getdata' from the 'NIMH 2' thread (http://forums.monkeylogic.org/post/show_single_post?pid=1303706273&postcount=189&forum=454793) here.

You are right. 'getdata' gives 'time' in seconds relative to the trigger command 'trigger(vid)' of the image acquisition with values like

(0.019; 0.0356; 0.0523;.. for each frame)
while 'metadata' values are in absolute clock time - 'AbsTime' - with values like

([2018,3,28,16,49,18.3171]; [2018,3,28,16,49,18.3338]; [2018,3,28,16,49,18.3504]; .. for each frame).

The problem is that the time of trigger is accessed by 'vid.InitialTriggerTime' which is in 'clock' time. So to actually use 'time' from 'getdata', one needs to use the trigger time which is in the imprecise clock time.

I was wondering if there is a way ML can use 'eventmarker' to access time of trigger relative to trial start.

Thanks.
0
Jaewon

Administrator
Registered:
Posts: 547
Reply with quote  #6 
I think the best way is to call eventmarker immediately after trigger and use the timestamp as the trigger time.

trigger(vid);
eventmarker(video_acquisition_start);  % time 0 of the image acquisition

Then align the video frames according to 'time' of getdata.
0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.