File Exchange

image thumbnail

CameraController

version 1.3.3 (15.2 KB) by Serge

Serge (view profile)

Controller for supported DSLR cameras via digiCamControl application

33 Downloads

Updated 22 Nov 2018

View License on GitHub

Controller (v1.3.3) for tethered DSLR cameras using digiCamControl app.
C = CameraController -create class
C = CameraController(dcc) -digiCamControl location
C = CameraController(dcc,debug) -set debug level
dcc: digiCamControl's webserver IP or CMD remote utility folder.
If empty this class tests the default webserver, 'localhost:5513', then
default app install locations, 'C:\Program Files (x86)\digiCamControl'.
debug: 0=silent, 1=minimal (default), 2=print requests, 3=print replies

Description:
-This class uses digiCamControl (windows only app) to control supported
cameras: set ISO, exposure, focus, aperture(fnumber), white balance,
stream liveview, capture photos & video, configure file download, etc.
-digiCamControl is a multi purpose, free, open source, Windows only
application that can control a host of supported cameras.

Setup:
1.Install and start digiCamControl v2.1.0 or greater:
https://sourceforge.net/projects/digicamcontrol/files/latest/download
2.Enable webserver: File>Settings>Webserver>Enable> RESTART APP
3.Connect one or more cameras using USB cable (or WiFi if supported?).
4.For full programmatic control set camera to (M) and lens to (MF).
5.Use digiCamControl app to ensure camera is working.

Remarks:
-This class communicates with camera(s) via digiCamControl's included
webserver(recommended) or CMD Utility.
-The webserver is much faster and allows camera(s) to be controlled from
any Windows/Linux computer on the network or via the internet.
-Visit http://digiCamControl.com for documentation, forums and to donate.
-Method in this class are Capitalised and have additional descriptions.
-When this class is created it does a one-off retrieval of allowed camera
options. Reinitialise this class when swapping cameras.

Limitations:
-This class can only stream liveview (low-rez, noisy, ~15Hz) from
supported cameras. However digiCamControl does support "Open Broadcaster
Software" (OBS) and "XSplit", see Streaming and Search Forums for info.
-Non-alphanumeric characters found in some Nikon camera properties are
being removed. These properties can be read but cannot be set.
eg "-", "." in "center-weighted_area" "active_d-lighting" "long_exp._nr"
-digiCamControl issues: http://digicamcontrol.com/phpbb/viewforum.php?f=4
-Focus method does not know how long it needs to wait after a focus change
is requested, see Focus method help to set custom delays.
-LiveView can only be 'streamed' when using the webserver.

Camera Settings:
-Some settings will not have affect if camera is not in Manual mode (M).
-To control focus ensure lens is set to Manual Focus (MF):
-Focus step size & speed can be modified in: File>Settings>Live view
-Note: Lenses use servo motors which have no discrete physical 'steps'. To
achieve a specific focus reproducibly try to go to the lens's physical
limit, in either direction, and apply the same 'steps' from there.

Image Capture:
-To reduce capture latency from 0.3-0.6 sec to ~0.05s ensure webserver is
enabled, File>Settings>Webserver>Enable>RESTART APP
-To measure delay and variance try imaging the computer's own clock by
calling the Clock method provided with this class, C.Clock, however
I do not know how to measure monitor display latency and variance.
-Cmd('CaptureAll') will trigger all connected cameras but there will be a
lag of 0.005-0.020 sec between consecutive cameras.
-To record video turn on live preview using Cmd('LiveViewWnd_Show') and
user Cmd('StartRecord') and Cmd('StopRecord').

Image Download:
-Download is affected by Transfer mode (in app) and session settings.
-Transfer mode is set via the main app to: PC & Camera | Camera only, if
set to Camera only some session settings will be ignored. Set it to PC
& Camera and use session setting "deletefileaftertransfer" if needed.
-session setting "filenametemplate" works only if "useoriginalfilename" is
disabled, and it is applied to downloaded files only, not camera files.
It supports many useful [tags], eg: [Date yyyy-MM-dd], [Time hh-mm-ss],
[Date yyyy-MM-dd-hh-mm-ss], [Exif.Photo.ExposureTime],
[Exif.Photo.FNumber], [Exif.Photo.ISOSpeedRatings], etc
(for a full list go to: Session>Edit Current Session>File Name Template)
-"filenametemplate" can be set when calling the Capture method and applies
to all connected cameras. To distinguish cameras use [Camera Name] or
[Camera Counter 4 digit] tags in the template.
-"folder" does not support [tags], instead use "\" in "filenametemplate".
-Manual download of files from the camera can only be done via the app.

Example:
C = CameraController; %initialise
C.session.folder = 'C:\DSLR'; %download settings
C.session.filenametemplate = '[Camera Name]\[Date yyyy-MM-dd-hh-mm-ss]';
C.camera.isonumber = 3200; %camera settings
C.camera.fnumber = 5.6;
C.camera.shutterspeed = 1/200;
C.Capture %capture
C.lastfile %last filename

Serge 2018
GitHub: https://github.com/serg3y/MatLab-digiCamControl
Bugs/fixes: s3rg3y@hotmail.com

Cite As

Serge (2018). CameraController (https://www.github.com/serg3y/MatLab-digiCamControl), GitHub. Retrieved .

Comments and Ratings (94)

Serge

Serge (view profile)

Updated, multiple cameras should work now.

Serge

Serge (view profile)

Hello Christopher,
Can you break point at line 344 and tell me what serials = ?
Also can you confirm that the second cameras also works when connected on its own?
I think the solution is to replace line 344 with:
if isempty(serials) || all(strcmpi(serials,'OK'))
Let me know if that works.

Serge,
Thank you for the submission, it worked great for one camera. However, when I went to control 2 cameras, I kept getting errors whenever I tried to initialize the camera controller object.

Operands to the || and && operators must be convertible to logical scalar values.
Error in CameraController/Cameras (line 344)
if isempty(serials) || strcmpi(serials,'OK')
Error in CameraController/CheckCamera (line 234)
[serials,err] = C.Cameras;
Error in CameraController (line 162)
[name,serials] = C.CheckCamera;
Error in CannonCameraImageAcquistion_20181105 (line 5)
C = CameraController;

I would appreciate any advice you have!

Serge

Serge (view profile)

Hello Heinz,
The "duplicate fields" error should have been fixed in the 4 August update of this class. Try downloading the current version and write back if there is still a problem.
Serge

Heinz Krause

Thank you for your application. However, I am runnign matlab 2017b and digicamcontroller 2.1.0.0 and get the following error:

seems like that this is a similar problem Guy reported. Did you find a solution?

Error using struct
Duplicate field name "lock"

Error in CameraController/get.camera (line 788)
s = struct(s{:}); %make a struct

Error in CameraController/Options (line 770)
params = fieldnames(C.camera); %list of parameters

Error in CameraController/CheckCamera (line 335)
C.options = C.Options; %cache camera options

Error in CameraController (line 267)
[name,serials] = C.CheckCamera;

Error in Acquisition_multipleDSLR (line 2)
C = CameraController('',4); %create class and auto-detect digiCamControl

Jan Gößling

Thank you, Serge. I will ask on digicam forum.

Serge

Serge (view profile)

Hello Alvaro, I don't think so I am afraid. I normally controller the focus manually from MATLAB.
If it's important you could also ask on the digicam forum.. "how to position green autofocus rectangle using the webserver" or request it as a new feature. Once the commands are added I could add it to the MATLAB interface.

Hi Serge, thanks for the application, it works very well! Is it possible to change the position of the green autofocus rectangle from matlab? I can move it from the livewiew of digicamcontrol, but manually using the mouse ...

Ian Hunter

Having just set this up, I am very pleased.
For newer users things that helped me set it up were:
1. Carefully reading the Setup section above
2. Restarting, then running digicam in the background, then running the example script.
3. Worked like a charm.

Serge

Serge (view profile)

Hello Stephen,
Afraid I am no good at C (or python). Having said that this wrapper is doing very simple stuff. It's got a lot lines that don't actually add any functionality. At the core are just basic http requests to digicamcontroll. If you don't care for a clean interface you should be able do that pretty easy. The "..examples.m" file with this subscription should provide http examples at the end to get you started and then there is digiCamControl documentation.

Sorry to be greedy, but can you provide a C or C++ version of this code?

Serge

Serge (view profile)

Hello Mohammad,
This is only a wrapper for the digiCamControl app.
If the app does not support video with your camera this class will not work either.
For a list of supported cameras go to: http://digicamcontrol.com/cameras
To request features from the developer go to: http://digicamcontrol.com/phpbb/
Good luck

Hey!
This is a very useful library to use, big thanks!
But I tried to record a video using this library as well as the desktop app.. I am not able to record for some reason.
I used, 'start' 'stop' on desktop app as well as Cmd command to go live, start and stop the process.

Thank you!
Cheers,
Hooman

Serge

Serge (view profile)

Hello Guy,
I tried digiCamControl v2.0.77.0 with the current version of the wrapper, using a Canon 600D and was not able to reproduce the error. Its the only camera I have now. I don't see how the current get.camera method can return a cell.... it should only return an empty char if there is an error or a struct.
With a break point at line 750 what does C.camera return? please email it to me.
As for serials.. it should be a cellstring. Again please email me what it actually contains.
I may be able to send you another version to test.
If you start with this line it should spit out a lot more text, when you get the error can you email me all that text?
C = CameraController('',4)
....

Guy Nir

Hi Serge

It is not too difficult to add some code to test if it is a struct and if not, convert the cell array to a struct.

I didn't want to start entering changes to the code (it is better, I think, if you add the new code at the source).

I did find that when switching to an older version of digicam (2.0.46.0) it all just works.

Serge

Serge (view profile)

Hello Guy
This feels a bit like an old problem, can you try the latest MatLab version.
If problem persists can you goto "function s = get.camera" and try to ensure it returns a struct?
If you find a solution please post it here or email me.

Guy Nir

Hi Serge.

Let me first say, this is very useful software.
I think there is a problem, however, with the new version of digiCam (2.077.0) with matlab 2017a and 2018a.
Some of the outputs from digicam seem to be given as cell arrays and not as scalars/strings/structs.
This causes some trouble...

I had one issue with function "Options" in line 750:
function [s,err] = Options(C)
%Get a list of valid camera options as struct of cellstr
params = fieldnames(C.camera); %list of parameters <<----- point of failure
for k = 1:numel(params)
[s.(params{k}),err] = C.List(['camera.' params{k}]); %list options for each parameter
s.(params{k}) = s.(params{k})';
end
end

The offending function is "fieldnames" which expects a struct but gets a cell array instead. (this is on 2018a with Nikon D700).
On another version with matlab 2017a and Nikon D610 I get an error in line 431. The offending variable is "serials" which is a cell array instead of a string.

thanks!

Serge

Serge (view profile)

Hello Luigi,
If you can use the web browser to capture then the problem *IS* with my MatLab..
Can you turn on debug:
C.dbg=2;
this should print all URL requests being sent out, and msgs reviewed too.
If "http://localhost:5513/?CMD=Capture" works from web browser we need to figure out what is MATLAB sending out and why it is not working..

Luigi Parente

Hi Serge,
Thank you for your response. I follow your suggestions but unfortunately I still get the same problem. D80 works when I go to http://localhost:5513/?CMD=Capture but it's not working through Matlab. I found v 2.0.0.0 but still is returnig the same message (access denied). I wrote to the developer. I'll let you know if they can help me with this.

Serge

Serge (view profile)

Hello Luigi,

This may still be an issue with the DigiCamControl application itself, or rather its back-end...

1. Ensure webserver is turned ON (File>Settings>Webserver>Enable *restart app*).

2. Connect camera with usb, open a web browser, goto:
http://localhost:5513/?CMD=Capture
Try with both cameras to confirm that D7000 captures and D80 does not.
(limited help here: http://digicamcontrol.com/learn/userguide/singlecmd#web-interface).

3. Also try the "Remote Utility", with both cameras, in windows command line run:
"C:\Program Files (x86)\digiCamControl\CameraControlRemoteCmd.exe" /c capture
(help here: http://www.digicamcontrol.com/doc/userguide/remoteutil).

4. (optional) can also try the "Command Line Utility", in windows command line run:
"C:\Program Files (x86)\digiCamControl\CameraControlCmd.exe" /filename C:\test.jpg /capture
(help here: http://www.digicamcontrol.com/doc/userguide/cmd).

5. (optional) Are you running "v2.0.76.1"? try an older version 2.0.69 (if you can find it) or else 2.0.0

If D7000 works and D80 does not with step 2 (web interface) and 3 (remote utility) then you will have to write to the developer, describe your tests and results and mention your app version. He is good and may be able to get it working quickly. Bug reports:
http://digicamcontrol.com/phpbb/viewforum.php?f=4

Write back how it goes...

Luigi Parente

Hi Serge, I have been working with DigiCamControl for a few weeks now and it's a really useful app.
I have a problem when working with Nikon D80. The problem is related to capturing photos. If I do it manually clicking on 'capture photo' it works well and image transferring is very quick. When I try to use 'C.Capture' in Matlab the acquisition doesn't work and I got a message on the DigiCam GUI saying 'ACCESS DENIED'.
I tried with 3 different Nikon D80 and I get always the same error message. Then I tried with a Nikon D7000 and it works fine. Unfortunately for my project I need to work with the 3 Nikon D80. Please could you help me in fixing this issue?
Please note that i'm using the last Digicamcontrol version and my cameras are connected to my laptop through USB cable. Thank you.

Jay Willis

Serge

Serge (view profile)

aya saeed, I am not sure what you mean...

aya saeed

could i use liveMode in the GUI ?

Serge

Serge (view profile)

Hey Patrick, try this new version, let me know if you find more issues.

Patrick

Hello, I received the error message below. DigiCam seems to work fine with my camera, which is a Nikon D7000. Am I doing something wrong to cause this error?:

Operands to the || and && operators must be convertible to logical scalar values.

Error in CameraController/Cameras (line 437)
if isempty(serials) || strcmpi(serials,'OK')

Error in CameraController/CheckCamera (line 330)
[serials,err] = C.Cameras;

Error in CameraController (line 265)
[name,serials] = C.CheckCamera;

Guy Nir

Wow this is super useful and super easy to use! exactly what we need for our astronomy project.. Thanks!!

Serge

Serge (view profile)

The list of supported cameras is here: http://digicamcontrol.com/cameras
There may be cameras not on the list but its best to check/ask the forum or make a feature request.
http://digicamcontrol.com/phpbb/

Abhay Sablok

Hello,
Just a quick question about other USB cameras that could be used with CameraController and digicamcontrol or does it have to be a DSLR?

Serge

Serge (view profile)

Hello Sofia, I am afraid it is not possible to pipe proper video quality to a computer from a DSLR via USB, using this class. It is only possible to quickly capture noisy live view frames, one after another, without sound, at low resolutions and inconsistent frame rate, jumping around from 10 to 20 fps for me. You can try the "stream live view" example in the description of the m file, to see the quality is enough for you, i suspect it will not be.

Also please see my comment bellow on "17 Jun 2017" and write back if you find out how to do it or if you find that it is too difficult.

SOFIA TAGINI

Dear Serge,
I need to stream a live video with a certain delay. In other words, I need to make a little bit of asynchrony between the video streaming and what's happening in the reality. May you help me?

Thanks a lot,
Sofia

Serge

Serge (view profile)

Hello Hadrien, Can you try this newest versions 1.3. Not it has quite a few changes and is still a work in progress.

Hadrien Bense

Hello, I have got this error. Digicam seems to run correctly my Nikon is well connected. But the connection between matlab and digicam fails. Any advice?

Error using struct
Invalid field name "center-weighted_area"

Error in CameraController/get.camera (line 472)
s = struct(s{:}); %make a struct

Error in CameraController/Options (line 458)
params = fieldnames(C.camera);

Error in CameraController (line 216)
C.cameraoptions = C.Options; %camera options

Serge

Serge (view profile)

@Mos Bay
Regarding pictures not saving to Camera, I can confirm that digiCamControl is a bit flaky. I found some settings do not to work via MatLab but work via the GUI. Go to bottom left of the GUI > "Transfer" drop down > select Camera Only. If that fails I can only suggest posting to the digiCamControl forums, sorry.

Serge

Serge (view profile)

@Mos Bay
You have to restart digiCamControl if you want to turn webserver on or off.
Commands with spaces will only work if webserver is on.

Mo Ba

Mo Ba (view profile)

@Serge
I got some issue after using DigiCamControl for a while.
First of all, I turned the Webserver on and after that my image filename template was mixed up and even after turning off and on the webserver, I still have the same issue. I don't know if there is any relation between turning on webserver and filename but i didn't do anything else so it should be! Indeed, my file name template was somthing like this:

C.session.filenametemplate = '[Time hh-mm-ss]_[Camera Name]';

and it saves the image by file name like this:
time_[Camera.jpg

where time is reall time but [Camera is a string not camera name!

Secondly, I chose to save pictures only on camera and not download it to PC to fasten speed. However, it always only saves to PC and nothing remains in Camera! In other words, I never have any picture in camera SD card!

Thanks in advance for your helps.

Serge

Serge (view profile)

@orlando you can stream LiveView to MatLab if Webserver is on:
C = CameraController;
C.Cmd('LiveViewWnd_Show') %start live view
C.Cmd('All_Minimize') %minimise digiCamControl app
clf(figure(1)); ah=gca; %create figure
while ishandle(ah) %loop until figure is closed
imagesc(imread('http://localhost:5513/liveview.jpg'),'par',ah), drawnow %display frame
end
C.Cmd('LiveViewWnd_Hide') %stop live view

Serge

Serge (view profile)

@orlando, digiCamControl comes with an "Open Broadcaster Software" plugin for streaming.
http://digicamcontrol.com/doc/usecases/live
But I have never used it, and I don't know if there is a way to stream to MatLab.
Also try searching the forums for "OBS": http://digicamcontrol.com/phpbb/search.php
If you do figure out if its possible or not, please post here.

@Serge is there a way to streaming real time video to MatLab or do you have an idea to achieve this? Thanks a lot!

Serge

Serge (view profile)

@Mos Bay
Afraid I have no good answer. You can try:
1) Skip downloading photos when shooting (C.property.nodownload = true). When done shooting downloading all via digiCamControl app (outside of MatLab). http://digicamcontrol.com/doc/userguide/interface/downph
2) It may be possible to run in burst mode if you want many shots in one second and then wait a loong time for download. I have never tried it, not what you are after i think.
3) If you need some idea of what you are shooting, download thumbnails only, that will hopefully download in 1 second (I have not tested it). Then user 1) to download proper images later, manually.
4) Go to the forums and request a new method to be added to "Single Command System" that would allow download of previously captured photos, if you need to be able to do the bulk download via MatLab. This is something I would like to see also. If added I could then make sure that this wrapper also supports it. The request may get ignored or it might get done in a week. http://digicamcontrol.com/phpbb/viewforum.php?f=5

Mo Ba

Mo Ba (view profile)

@Serge Just for your information, I send 'C.Cmd('CaptureAll') ;' command every 0.5s to capture picture using two cameras. But as I tested the performance of my program, I only get one picture per two seconds! I put a stopwatch in front of camera lenses to check this. Do you know what the problem might be and how can I fasten this and let's say 2 pictures per second?
Thanks

Mo Ba

Mo Ba (view profile)

@Serge is there any way to download all images after capturing? I mean a command to download all pictures not merely the last picture by C.lastfile.
I can download pictures each by each using C.lastfile but as we discussed before, I have the delay problem and thought it's a good idea to capture all images and store them in SD card and then download them in my computer. This can significantly decrease the delay I believe.
Thanks

asma arafat

aya saeed

Kryptonite21

@Serge

Thank you so much for your prompt response. I will surely try the bracketing feature and the MATLAB code. I am basically using MATLAB to code all the necessary work related to my project that is why I was looking for something in MATLAB itself.

Serge

Serge (view profile)

@Siddhant Aphale
Should not be a problem, for exposures longer then about 2 seconds you will want to add a pause, else the camera may not be ready to capture the shot after:
C.camera.shutterspeed = '1/30'; C.Capture('33ms');
C.camera.shutterspeed = '1/15'; C.Capture('66ms');
...
C.camera.shutterspeed = '5'; C.Capture('5000ms'); pause(5)
...

You may not need MatLab at all since digiCamControl has a number of bracketing features and also supports scripts if you need something more specific. http://digicamcontrol.com/doc/userguide/interface/bracketing

Kryptonite21

Hello,

I want to capture continuous images, say 7 images but all at different exposure times in a single trigger. Is it possible to set an array of shutter speeds and then run the capture command in a for loop?

I have not actually tried doing it as I am new to controlling camera from computer and I don't want to mess something up. I have a Nikon D5500 and I want to maintain ISO of 100, capture RAW images at exposure times of [1/30, 1/15, 1/8, 1/4, 1/2, 1, 2]. Thank you for your time.

Serge

Serge (view profile)

@asma aragat
Hmm, Can you run this in MatLab (when digiCamControl is running camera is connected) and post the reply here or email to me s3rg3y@hotmail.com:
system('"C:\Program Files (x86)\digiCamControl\CameraControlRemoteCmd.exe" /c List camera)
(if you have windows 32bit or you installed to a different location you will need to fix the path)

asma arafat

@Serge
there is an error when i run this code. here is the error
Index exceeds matrix dimensions.
Error in CameraController/get.camera (line 471)
s(1,:) = strrep(s(1,:),'.',''); %remove any dots, Nikon has a setting "long_exp._nr"
Error in CameraController/Options (line 458)
params = fieldnames(C.camera);
Error in CameraController (line 216)
C.cameraoptions = C.Options; %camera options
Error in Untitled (line 1)
C = CameraController; %initialise

asma arafat

there is an error when i run this code. here is the error
Index exceeds matrix dimensions.

Error in CameraController/get.camera (line 471)
s(1,:) = strrep(s(1,:),'.',''); %remove any dots, Nikon has a setting "long_exp._nr"

Error in CameraController/Options (line 458)
params = fieldnames(C.camera);

Error in CameraController (line 216)
C.cameraoptions = C.Options; %camera options

Error in Untitled (line 1)
C = CameraController; %initialise

Serge

Serge (view profile)

@aya saeed
What happens when you execute the second example while digiCamControl is running and your camera is connected to PC with a USB cable?
C = CameraController; %initialise
C.Capture('FileName') %capture and download image as "FileName.jpg"
file = C.lastfile %get last downloaded filenames

asma arafat

i have dslr camera (Nikon D3400), i want to capture image from matlab using digicamcontrol, what is the command should i use to do this.

Serge

Serge (view profile)

@aya saeed
It is not possible to stream live view to MatLab using this class. You can take photos or start stop video collection. digiCamControl then downloads the photos to hard drive, when done you can open them with MatLab again.

aya saeed

I have downloaded the .m file and digiCamControl program But I can't move any step after that , I want to open the live mode and capture the image from the matlab but i don't know from where I should begin ... could you help me , please !

Mo Ba

Mo Ba (view profile)

@Serge
Now it works perfect! Thanks for such a great project!
Just to let you know:
1) I used the recent method you mentioned and now I can capture pictures at the same time and can save them with file name I need with no problem.
2) I marked the Webserver in File>>Setting (Start when windows starts), but as I see when I run MATLAB code, it says Webserver: off. So either I didn't turn the Webserver on or it just shows like this in MATLAB! But the speed is pretty good now anyways.
3) Just as a question, I can see the name of Xiaomi Yi action cameras in Wifi list! Does it mean DigiCamControl supports a Yi action camera as well??? I tried different ways to connect to a GoPro but achieved nothing. However, a Yi camera is better than a GoPro in my opinion and if we can use it in DigiCamControl that would be awesome!

Thanks alot for your help and time and I'll get back to you in future if I got a problem.

Serge

Serge (view profile)

@Mos Bay
The first example i gave on 1 May 2017 can never work because C.session.filenametemplate is a session setting not a camera setting, ie it is same for all cameras.
However the "Example: two cameras" from the description should have worked...
Here is a another short example for two cameras:
C = CameraController;
C.Cameras(1), C.property.devicename = 'Cam1'; %set camera names (one-off)
C.Cameras(2), C.property.devicename = 'Cam2';
C.session.filenametemplate = '[Time hh-mm-ss]_[Camera Name]'; %set filename pattern
C.Cmd('CaptureAll')
> this should create two files with names such as:
22-19-17_Cam1.jpg
22-19-19_Cam2.jpg
Note: photos should be collected almost simultaneously, the time stamps show when files are downloaded not captured.

Serge

Serge (view profile)

@Mos Bay
1) Does it take 3 sec to release the shutter or to download the photos?
Webserver will not speed up download, it only speeds up sending commands.
Webserver is NOT related to WiFi.
To turn Webserver on goto File>Settings>Webserver and restart digiCamControl.
You should not have to change any code.
Don't forget about digiCamControl user guide: http://digicamcontrol.com/doc/userguide
Use the second method for now if its suitable.

Mo Ba

Mo Ba (view profile)

@Serge. Great. It works. However, when I used filenametemplate and CaptureAll commands, I got problem in file naming. I mean It didn't save with the file name I assigned for camera #2. But the second method works for me .
About the delay, can i ask how to use Webserver? because I reduced the file size and it still seems slow. It might seems a basic question but I can't get it work. What I do is enabling wifi on my camera and then in DigiCamControl I select the wifi icon. But in the list there is nothing for Canon! It shows two options for Nikon, one for an action camera and I don't exactly know what is the last one for!
I saw the example provided, but didn't understand it exactly. Is it possible to give me an example how to capture pictures by both cameras and save them by specific filename as before using WebServer?
Thanks again.

Serge

Serge (view profile)

@Mos Bay
1) Does it take 3sec to release the shutter or to download the photos?
If it's 3 sec to release the shutter then make sure you have turned on the Webserver in digiCamControl (&restarted).
If it's 3 sec to download then you could try taking smaller resolution images, experiment with different usb cables, different USB ports, different computer, but i would expect some delay here
2) Try this
C = CameraController;
C.Cameras(1), C.session.filenametemplate = 'This_was_taken_by_camera1';
C.Cameras(2), C.session.filenametemplate = 'This_was_taken_by_camera2';
C.Cmd('CaptureAll')
Or this (if photos do not have to be simultaneous)
C = CameraController;
C.Cameras(1), C.Capture('This_was_taken_by_camera1');
C.Cameras(2), C.Capture('This_was_taken_by_camera2');
Good luck

Mo Ba

Mo Ba (view profile)

@serge Thanks for help. It works now after installing beta version. But I have two concerns and I post here because might be useful for someone else in future:

1. It seems in this version the process of taking picture is slower. It takes longer to send a command and taking the actual picture. Do you feel the same? This is more obvious when I use multiple cameras capability and it's really slow (there is more than 3 sec. delay I believe). Do you have any suggestion to fasten this process?
2. I can take picture with both cameras using this example:

C = CameraController;
C.Cameras(1), C.camera.isonumber=3200; C.camera.shutterspeed='1/1000';
C.property.devicename = 'Cam1';
C.Cameras(2), C.camera.isonumber=3200; C.camera.shutterspeed='1/1000';
C.property.devicename = 'Cam2';
C.Cmd('CaptureAll')

My question is, how can I save each picture by their own specific file name as before? I mean something like this command:

C.Cameras(1).Capture('This_was_taken_by_camera1') ;
C.Cameras(2).Capture('This_was_taken_by_camera2') ;

This was just an example and I know it doesn't work, but there should be a solution for this.
Thanks again for your time.

Serge

Serge (view profile)

@Mos Bay
1) You have to install the latest *beta* version of digiCamControl (v2.0.69 or greater) https://sourceforge.net/projects/digicamcontrol/files/latest/download
2) You have a different version of this class because your line 494 is line 493 for me, try downloading it again. and try again.
3) Check in digiCamControl app what does it say for Session>Edit Current Session>File Name Template?
4) Is this setting on or off? Session>Edit Current Session>Use original filename
5) What does this return? >> C = CameraController, C.session, C.session.useoriginalfilename
6) Re-post any error messages or email to s3rg3y@hotmail.com

Mo Ba

Mo Ba (view profile)

@Serge
I'm using V 2.0.0.0 as I see.
About showing pictures my problem is solved, thanks. But saving by my desired file name still doesn't work. Firstly, when I use this command:

C.session.useoriginalfilename = 0

I get an error like this:
Reference to non-existent field 'useoriginalfilename'.
Error in CameraController/set.session (line 494)
C.Set(['session.',f{1}],new.(f{1}),old.(f{1}),'');

The problem is when I enter C.Capture('mytest') command, regardless of my file name (which is mytest here), the camera saves pictures by default file name.
As I mentioned before, I need to have something like this :

for k=1:10
C.Capture(['Any_File_Name_Can_Go_Here_But_Spaces_Will_Not_Work_ID' num2str(k)])
end

but for some reason I can't . If you need me to do more tests please let me know.
Thanks

Serge

Serge (view profile)

@Mos Bay
1) Check in digiCamControl what does it says for Session>Edit Current Session>File Name Template?
(should be same as: C.session.filenametemplate)
2) Also is this turned off: Session>Edit Current Session>Use original filename?
(should be same as: C.session.useoriginalfilename)
3) What version is your digiCamControl: Help>About ?

To load and display an image you can do:
file = fullfile(C.session.folder,C.lastfile);
I = imread(file);
imshow(I)

Mo Ba

Mo Ba (view profile)

@Serge finally I got my camera and have started testing. To test everything is working, I tried this example:

C = CameraController;
C.Capture('mytest')
file = C.lastfile

After running, camera takes picture, but the file name is not what I assigned. In this example, I set the name for "mytest" but the name after capturing is the default name (DSC_0004.jpg). Am I missing something here?
The next question is here I just get the file name, how can I get the actual picture and show it as an Image in MATLAB?

Thanks

Serge

Serge (view profile)

@Mos Bay, Tethered simply means connected to computer via USB cable.

Mo Ba

Mo Ba (view profile)

@Serge thank you so much. I really can't wait more to try this myself after I received my 70D.
I was thinking DigiCamControl seems awesome because i will not need to use IMWRITE command to save pictures and this will improve the speeed significantly.
By the way can I ask what do you mean by tethering via USB and how do you tether 70D?
And I'm curious to try webserver. I will try soon.
Thanks again.

Serge

Serge (view profile)

@Mos Bay, Correction, it seems I *can* operate a Canon 70D and a 600D without SD cards. There is no internal storage at all on either camera.
When 70D is not tethered it refuses to shoot without SD. When 600D is not tethered it shoots but no photos are saved to the camera when without SD. But when tethered to PC via USB both cameras shoot and save to PC without SD cards.

Serge

Serge (view profile)

@Mos Bay, Sorry there was a bug in version 1.2 (if you downloaded between 18 Apr and 12 Apr) where the file and time inputs were being ignored to the Capture method. Latest version 1.2.1 should work now.
for k=1:10
C.Capture(['Any_File_Name_Can_Go_Here_But_Spaces_Will_Not_Work_ID' num2str(k)])
end

Mo Ba

Mo Ba (view profile)

I think it's not possible to edit comments here so I'm adding this to my last comment.
I meant in this line:

C.Capture('FileName') %capture and download image as "FileName.jpg"

Can 'FileName' be a string type variable which I'm changing the string in a loop before capturing?

Mo Ba

Mo Ba (view profile)

Mo Ba

Mo Ba (view profile)

Thank you for explanation. About file naming I'm a bit confused. What I'm planing to do is saving captured picture by a dynamic file name. Let's say I'm creating a custom dynamic string which is being change before taking each picture in a loop and then I want to save the picture by my own created string. Do you think I can do it by digiCamControl?

Serge

Serge (view profile)

digiCamControl sends the command to camera to take a picture, which is saved by the camera to the camera, where the camera determines the file name. Then (depending on settings) digiCamControl tries to download the last capture to hard drive and rename it as per settings. Again depending on setting the file is either removed or kept on the camera side.
Some cameras have a little bit of their own storage space, for show purposes. I will check tonight if my Canon can work without an SD, but i suspect not, i suspect it will need an sd that can hold at least one image.

Mo Ba

Mo Ba (view profile)

A question Serge. For my application, I just need to get snapshot and write images with my own file name into image files on the computer and don't need images on camera. So Ibwas wondering do I still need to have a SD card on my camera? When you command camera to take picture, does it save on camera or as a variable in Workspace?
Thanks

Mayank Jain

Hi Serge,
I am working on an academic project of mine and wanted to know how I can control the focus via MATLAB as in capturing different images at various focus steps via code.

Mo Ba

Mo Ba (view profile)

Thank you Surge for prompt reply. I ordered a Canon 70D to start my experiments. I will share my results with you as soon as I received the Camera. Now I have many questions but don't want to ask before trying this interesting code.

Serge

Serge (view profile)

@Shubham please try the last example in the latest version. You may want to try enable the Webserver in digiCamControl to speed up commands, though i have not tested it properly.

@Mos Bay, you may also be interested in trying the Webserver as it should bring down latency of immediate captures to about ~0.05 sec.

How do you control the file naming when shooting multiple shots through Do('CaptureAll')?

Serge

Serge (view profile)

I only used it on 64bit OS/MatLab, but all it is doing is talking to a 32 bit application (digiCamControl is 32bit). Please email any bugs reports/strange behavior to s3rg3y@hotmail.com or post here.

Mo Ba

Mo Ba (view profile)

Thanks Serge. Just a question, has this code been tested on both 32 and 64 bit OS / MATLAB?

Serge

Serge (view profile)

The delay should be in the range of 0.2 to 0.4 sec. Perhaps extra for the very first picture if MatLab or the operating system decides to have a think about something. You can try displaying the computer's own clock on screen (with milliseconds) and imaging that clock. Once you know what the delay is you can adjust for it, provided you know in advance when you need the photo. You may find you will still get a bit of variance of +-0.03s or so.
There may be a way of reducing the initial 0.2 to 0.4 sec delay by using the web server. Let me know if you need this.

Mo Ba

Mo Ba (view profile)

This looks what I have looked for a long time! May I ask what's the delay between sending command to take picture and taking actual picture by camera?

Serge

Serge (view profile)

@Jairo Ordóñez Oliver
Can you break point at line 371, evaluate s on the command line, and email to me, or msg here.

Also what camera are you using and can you control it fine with the digiCamControl App?
Also what version of the App do you have?

Any idea for how to solve this problem?

Index exceeds matrix dimensions.

Error in CameraController/get.camera (line 373)
s(1,:) = regexprep(s(1,:),{'\.' '__'},'_'); %replace any "." and "-" with "_"
because Nikon has setting "long_exp._nr" "active_d-lighting"

Error in CameraController/Options (line 360)
params = fieldnames(C.camera);

Error in CameraController (line 181)
C.cameraoptions = C.Options; %camera options

You are absolutely right, about that. Yeah the latest beta doesn't have this problem. Cheers

Serge

Serge (view profile)

@Nicholas McMullin,
What version of digiCamControl are you using?
I think this or simular issue was resolved somewhere after v2.0.4x. Try the latest beta v2.0.69.

So I have solved my own problem with an inelegant fix. The issue is that for some reason when requesting the current f stop values or the f stop options from the Canon 550d or 400d, the values are given as 'Ÿ/3.2', however when sending the command from matlab to DigiCamControl, it must send it as 'ƒ/3.2'.

My brute force fix was to, just before Run sends the command via
[fail,msg] = system(cmd);
to check the cmd value, find any instances of the Ÿ character and replace it with a ƒ.

Any more elegant solutions would be appreciated.

Hi,

Thank you for this script it is really helpful!

I'm having one issue with setting the fstop on a Canon EOS 550d. When I interrogate what the fnumber is (by entering C.camera.fnumber) it returns the string 'Ÿ/3.2', however when I try to set the fnumber with

C.camera.fnumber = 'Ÿ/4.0';

it prints: camera.fnumber: Ÿ/3.2 > Y/4.0

and fails to change the setting on the camera (Note the lack of umlaut on the second Y character).

Any ideas how I would solve this problem?
Cheers

Serge

Serge (view profile)

@Dominik F, Many thank!
Version 1.1.1 now has this for line 373:
s(1,:) = regexprep(s(1,:),{'\.' '-' '__'},'_');
Let me know if there are any other issues.

Dominik F

Dominik F

Hey,

in line 373 you remove the dots from the settings labels. I also added a line where the minuses from settings labels are replaced because I got an error connecting my Nikon D5300. It has a setting "active_d-lighting" which causes trouble creating the struct later on. Maybe you can make sure whether this is a feasible solution.

cheers,
dom

Serge

Serge (view profile)

@Fatma, can you (or someone) send me:
1) the whole error message
2) camera model used
3) digiCamControl software version used
to: s3rg3y@hotmail.com
or post here.

Fatma

Fatma (view profile)

Hello,
I installed the package and program works well but;

C = CameraController;

When I use this command in MATLAB I got this error in command window

Error using struct
Invalid field name "sonumber"

Do you know about this problem?Thanks

Guy Nir

cool! this will be very useful for testing our telescope mount using the nikon as surrogate for the telescope :)

thanks a lot!

Updates

1.3.3

-fixed multiple camera support
-improved multiple camera example

1.3.2

-webserver IP can include a port number (default: 'localhost:5513')
-capture "lag" now a property rather then input to Capture method
-fixed error with duplicate fields on Nikon
-debug property no longer hidden

1.3.1.2

comments

1.3.1.1

Just comments changes

1.3.1.0

Now source is on GitHub.

1.3.1.0

forgot the file

1.3.1.0

bunch of small changes and fixes

1.3.0.0

-Support a remote http server
-Better error handling
-Allow commas in filenames
-Minor changes and better help

1.2.1.0

Fixed issue with Capture method ignoring file and time input.
Updated description and focus stacking example.

1.2.0.0

Added Webserver support.
Many other small changes.

1.1.1.0

Improved support for Nikon, by allowing field "active_d-lighting" as "active_d_lighting"

1.1.0.0

forgot to update code

1.1.0.0

-update to digiCamControl 2.0.46.0
-setting fnumber should work properly now
-many minor changes

1.0.3.0

spelling

1.0.3.0

A bit of everything, mostly help.

1.0.2.0

A little bit of everything

1.0.2.0

Improved the "Capture" method.

1.0.1.0

Updated description

1.0.1.0

Fixed Do method

1.0.1.0

Changed Do method, other minor changes

1.0.0.0

Added a hack to run Do commands by assigning to the Do property

1.0.0.0

update title

1.0.0.0

update description

1.0.0.0

Requirements modified

MATLAB Release Compatibility
Created with R2018a
Compatible with R2012a to R2018b
Platform Compatibility
Windows macOS Linux

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.


Learn About Live Editor