I am trying to automate the camera to take an image every 3 seconds for the next 30 seconds and then to append the image to list.
dev = DeviceOpen["Camera"]
DeviceRead[dev]
AppendTo[snapshots, DeviceRead[dev]]
RunScheduledTask[AppendTo[snapshots, DeviceRead[dev]], {3, 10}]
But the code is not responding as wanted.
mthiel
(Marco Thiel)
April 24, 2017, 11:26pm
2
Hi Jose,
I suppose the problem is that you haven’t initialised the variable “snapshots”.
dev = DeviceOpen["Camera"];
snapshots = {};
RunScheduledTask[AppendTo[snapshots, DeviceRead[dev]], {3, 10}];
Then you should remove the scheduled task(s):
RemoveScheduledTask /@ ScheduledTasks[]
Cheers,
Marco
Sorry.. but you code does to produce any result not the list of the 10 images taken 3 seconds apart.
mthiel
(Marco Thiel)
April 25, 2017, 8:41pm
4
Hi Jose,
what system are you on. For me it does work:
dev = DeviceOpen["Camera"];
snapshots = {};
RunScheduledTask[AppendTo[snapshots, DeviceRead[dev]], {3, 10}];
Partition[snapshots, 2] // TableForm
Cheers,
Marco
I am on “11.1.0 for Mac OS X x86 (64-bit) (March 16, 2017)”.
I retrieved the images after entering the list. The only issue left is that the camera hang-up on. I added the DeviceClose[“Camera”] , but this closes the camera before taken the 10 images.
I know that this is a separate issue, but it is very important for a automation task since I will have multiple cameras doing different task and will need the code to turn off the camera when finished with the images.
neils
(Neil Singer)
April 27, 2017, 3:38am
6
Jose,
Make sure you are waiting to close the device:
dev = DeviceOpen["Camera"];
snapshots = {};
tsk = RunScheduledTask[AppendTo[snapshots, DeviceRead[dev]], {3, 10}];
RunScheduledTask[DeviceClose[dev], {35}];
or do a Pause[35] before closing the device
Follow this with:
RemoveScheduledTask[ScheduledTasks[]];
Partition[snapshots, 2] // TableForm
This runs for me on a Mac with 11.1.0