File Exchange

image thumbnail


version 1.3.3 (14.4 KB) by Serge
Controller for supported DSLR cameras via digiCamControl application


Updated 22 Nov 2018

From GitHub

View Version History

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

-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.

1.Install and start digiCamControl v2.1.0 or greater:
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.

-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 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.

-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:
-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.

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

Serge 2018

Cite As

Serge (2021). CameraController (, GitHub. Retrieved .

Comments and Ratings (119)


Hello Vito,
Sorry for late reply. This MATLAB wrapper simply communicates to digicam via its remote utility. Ensure you enabled web server in digicam>restart digicam> try to take a picture via a web browser (see dicam website for help). If that works then it should be possible to get this MATLAB wrapper to work also, as that is all it does, send url requests.

Vito Ko

Hi Serge, thank you for your contribution to creating this app. I am using Sony A7 ILCE-7M2 for my research and it is successfully connected to Digicamcontroller App through wifi. However, the Matlab code does not work for this case and I cannot find an answer for that until now. Is the Matlab code not compatible with Sony camera?



This is just a wrapper for digiCamControl, which is free. states:
"The application is free to use under MIT license even in commercial applications. Moreover, you can download the source code and modify it for your needs."
If you like digiCam software you can donate to support the developer.

Paul Kenney

Hi Serge,

Are you licensing this software? I saw no licensing information on Github and wanted to try this out with my company computer.

Thanks, Paul

Marco Turrini

Hello Serge!

I am trying to use digicam control to turn my camera into a measurement device for which I need regularity in the photographs. I have tried a standard code (below) and by recording the "clicks" of the camera I have found out that the photos are taken on average at 1.54s with a decent regularity (0.05s of standard deviation). Now, I believe my camera can do better than that (CANON EOS 60D) but I don't understand how? I have tried to change the drive_mode but the results have been identicals.

Am I missing out on something major to the use of either digicam or your controller?

Any tips on how I could improve the regularity of the photos taken?

Thank you and have a good day



close all
C = CameraController;
C.session.folder = 'C:\Users\ENDLab_W10\DSLR\Photos';
C.session.filenametemplate = char(datetime(now,'ConvertFrom','datenum'));
C.session.useoriginalfilename = 0; %ignores "filenametemplate"
C.session.downloadthumbonly = 0; %not working (v2.0.72.9)
C.session.downloadonlyjpg = 0; %only used if "PC+CAM"
C.session.deletefileaftertransfer = 1; %only has affect if Transfer="Cam+PC" and affectively converts it to "PC only"
C.session.asksavepath = 0; %dialogue pop-up for after capture
C.session.allowoverwrite = 0; %overwrite if file exists
C.session.lowercaseextension = 1; %use "*.jpg" instead of "*.JPG" = 1600; = 6.3;
C.lag = 0.05; = 1/50; = 'Large Fine JPEG'; = 'Single-Frame Shooting';
pause(5) %wait for any vibration to stop
Nphotos = 200;
stp = floor(Nphotos/10);
for i = 1:Nphotos
if ~mod(i,stp)
disp([ num2str(i) ' out of ' num2str(Nphotos) ' photos '])


Keywords: timing, delay, regularity,


Casey, email me everything from command line with debug set to max.
Which MATLAB are you running? My email is in the description...

Marco Turrini

Is it just me or this toolbox is only available for Windows as digiCamControl is for Windows only?

Casey Ladtkow

I'm Having an issue with the web interface. When digiCamControler is running with the web interface enabled, I can paste 'http://localhost:5513/?CMD=LiveViewWnd_Show' into a browser and see the preview but when I try to connect to the camera with 'C = CameraControler', I get "No Camera Detected". I tried some debugging and it looks like there is a problem with urlreadwrite but I can't get much further than that. Any help would be appreciated. Thanks.

Thomas Wocial


Hello, this wrapper is using digiCam's web interface. You probably need to recreate the problem using a web browser and post about it on the digiCam forum...

Helen Fisher

Hi Serge,
I'm using a Sony a7s, and the only way I've gotten liveView on digiCam to work, with this specific camera, is by connecting the camera through wifi and not by usb connection. Then when I run it with this matlab code, it can't seem to find the camera and says "No camera detected". Is it possible to use this code to access cameras connected to digiCam through wifi, or can you only use it on cameras connected through usb? Are there any changes to the code that can fix this problem?


Thanks for advices.
>Are you sure its the mirror and not the shutter?
I have asked a few images in LiveView mode, camera lockup mirror mode is activated. Between these images I see image in camera's viewfinder, so mirror is flipping.

>Search the digicam forums:
In fact, no issue with lockup mirror (LiveView) mode in DigiCamControl, it works correctly.

So, it means that either camera don't received signal lookup mirror signal, or my camera "not understand" it, if your camera works correctly.


Are you sure its the mirror and not the shutter? For me (Canon 70D) i only see the shutter and not the mirror swing past when in LiveView.
I think Canon camera has a mode where it can reduce shutter movements also but i don't know if its supported in digicam.
First search mirror lockup with your camera on the web:
Search the digicam forums:
Maybe start a thread, note you are essentially using this "web interface":
Finally ask for support or a feature request.
Email me any threads you start so i can keep an eye.


Thanks a lot for proposal. I have tested it. LiveView is switched on (mirror up), but C.Capture produced returning mirror to initial state (mirror down), than exposition and again mirror up. After pause process is repeating. Shortly speaking, C.Capture produced exposition with mirror movement independently of LiveView. It not depends on RAW/JPEG file format. Also I try to change drive mode without success.

Has CameraController some indication of file transfer to PC finish? It would be useful to avoid overlapping of different operations.


Hello Valeriy,
The only way i know how to do this in digiCamControl is by turning on liveview to retract the mirror.
If you know another way please let me know.
Note: with liveview you can shoot RAW or JPEG, but not both, at least not using Canon 70D.
C = CameraController;
C.Cmd('LiveViewWnd_Show'); %live view on (open mirror)
pause(0.5) %wait for any vibration to stop
C.Capture %capture
C.Cmd('LiveViewWnd_Hide'); %live view off (close mirror)


Is it possible to make set of images without camera mirror movement? Or to send image from Live View into file? Camera is fixed with microscope and mirror movement producing vibration.


Can you replace line 777:
if ~contains(t,'CameraControl.exe')
if isempty(regexp(t,'CameraControl.exe','once'))


I modified line 656 as you proposed. I run C = CameraController;
Result is following:

??? Undefined function or method 'contains' for input arguments of type 'char'.

Error in ==> CameraController>CameraController.TestCMD at 777
if ~contains(t,'CameraControl.exe')

Error in ==> CameraController>CameraController.CheckConnection at 197
[status,err3] = C.TestCMD(C.dcc);

Error in ==> CameraController>CameraController.CameraController at 155
if C.CheckConnection(C.dcc) %prints error msgs, if any


Valeriy can you test for me...?
For that particular problem replace line 656 with:
[~,i] = unique(s(1,:)); i = sort(i);
Let me know if there is another error else where...


I'll install 2011a and have a play on the weekend, its just a few lines that need changing, but no promises.


Hello, Serge,
Thanks for reply, for information about DigiCamControl author.

>Check 2012 first please.
I have asked this question in "Answers" several days ago, but I still don't have (and, probably, will not have) answer on this question. Nobody from my colleagues and friends has this version.

>Then try to modify the code yourself perhaps? if you succeed send me a copy and ill put it up.
Of course, I will, if it will manage me to find correction. From other hand, I'm a bit pessimistic about my possibility to understand logic and architecture of code, which is written by somebody else. Additionally, I never used DSLR library...

>Otherwise you might have to wait some time till i get my hands on a DSLR...
Could you estimate possible wait time? Days, weeks, months, years?

Anyway, thank you


Hello Valeriy,
Duka Istvan is the main developer of DigicamControl and I feel the same about the software! (I only know MatLab...)
I don't actually have a DSLR right now, so it will be tricky for me to make changes.
Check 2012 first please. Then try to modify the code yourself perhaps? if you succeed send me a copy and ill put it up. Otherwise you might have to wait some time till i get my hands on a DSLR...


Hello Serge,

Thanks for your prompt reply.
>Are you able to update to later version of MatLab? 2016+ to be safe. 2012 or 2014 may work.
My challenge is strong necessity to control hardware by parallel port, support of which is disappearing in later Matlab versions. I'm not sure that 2012 version is still supported it, I'll try to study this question.

By the way, are you author of DigicamControl package? If so, please, accept my sincere compliments for this excellent work. Many years I try to find something similar, but only DigicamControl provided very powerful and useful DSLR camera control.


Hello Valeriy,
Yes 2011 is a bit too old and does not support 'stable' input for unique.
It would not be hard to modify for old MatLab, but there are probably a few places that would need fixing.
Are you able to update to later version of MatLab? 2016+ to be safe. 2012 or 2014 may work.


Hello Serge,
Thanks a lot for your submission. I'm very interesting in application of CameraController, but I met following issue.

I installed DigicamControl program, it works well with my Canon EOS Rebel T1i camera.
Than I have performed all initialization operations, listed in CameraControl.m file.
When I try following command

C = CameraController;
I see next message:

connection type is: 'HTTP' (capture lag set to 0.05 sec, affects only "timed capture")
digiCamControl location is: 'localhost:5513'
??? Error using ==> cell.unique at 28
Unrecognized option.

Error in ==>
CameraController> at 656
[~,i] = unique(s(1,:),'stable'); %bug in
digiCamControl causes some fields to be
returned twice (eg v2.0.77.0 returns
'lock' twice for Nikon D3400, reported
by Marek) should this hack
Error in ==> CameraController>CameraController.Options at 637
params = fieldnames(; %list of parameters

Error in ==>
CameraController>CameraController.CheckCamera at 239
C.options = C.Options; %cache camera options

Error in ==>
CameraController>CameraController.CameraController at 164
[name,serials] = C.CheckCamera;

What could be the reason of such reaction?
I'm using Matlab R2011a, is this critical limitation?

Thanks a lot for help


Updated, multiple cameras should work now.


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.

Christopher Wiegman

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!


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.

Heinz Krause

Thank you for your application. However, I am runnign matlab 2017b and digicamcontroller 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/ (line 788)
s = struct(s{:}); %make a struct

Error in CameraController/Options (line 770)
params = fieldnames(; %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

Alvaro Toribio

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


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.

Alvaro Toribio

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.


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.

Stephen Schachter

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


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:
To request features from the developer go to:
Good luck

Mohammad Tavassolian

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!


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 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 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 ( it all just works.


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 =" 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(; %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})';

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.



Hello Luigi,
If you can use the web browser to capture then the problem *IS* with my MatLab..
Can you turn on debug:
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 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.


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:
Try with both cameras to confirm that D7000 captures and D80 does not.
(limited help here:

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:

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:

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:

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


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

aya saeed

could i use liveMode in the GUI ?


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


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!!


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

Abhay Sablok

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


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.


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,


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/ (line 472)
s = struct(s{:}); %make a struct

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

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


@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.


@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

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:

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.


@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
C.Cmd('LiveViewWnd_Hide') %stop live view


@orlando, digiCamControl comes with an "Open Broadcaster Software" plugin for streaming.
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":
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!


@Mos Bay
Afraid I have no good answer. You can try:
1) Skip downloading photos when shooting ( = true). When done shooting downloading all via digiCamControl app (outside of MatLab).
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.

Mo Ba

@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?

Mo Ba

@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.

asma arafat

aya saeed



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.


@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: = '1/30'; C.Capture('33ms'); = '1/15'; C.Capture('66ms');
... = '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.



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.


@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
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

there is an error when i run this code. here is the error
Index exceeds matrix dimensions.
Error in CameraController/ (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(;
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/ (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(;

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

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


@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.


@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

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.


@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), = 'Cam1'; %set camera names (one-off)
C.Cameras(2), = 'Cam2';
C.session.filenametemplate = '[Time hh-mm-ss]_[Camera Name]'; %set filename pattern
> this should create two files with names such as:
Note: photos should be collected almost simultaneously, the time stamps show when files are downloaded not captured.


@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:
Use the second method for now if its suitable.

Mo Ba

@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.


@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';
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

@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),;'1/1000'; = 'Cam1';
C.Cameras(2),;'1/1000'; = 'Cam2';

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.


@Mos Bay
1) You have to install the latest *beta* version of digiCamControl (v2.0.69 or greater)
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

Mo Ba

I'm using V 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)

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)])

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


@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);

Mo Ba

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

C = CameraController;
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?



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

Mo Ba

@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.


@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.


@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)])

Mo Ba

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

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?


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

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?

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

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.


@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.

Shubham Trivedi

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


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 or post here.

Mo Ba

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


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

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?


@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/ (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(;

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

Nicholas McMullin

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


@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.

Nicholas McMullin

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.

Nicholas McMullin


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 it returns the string 'Ÿ/3.2', however when I try to set the fnumber with = 'Ÿ/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?


@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


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.



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


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!

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

Community Treasure Hunt

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

Start Hunting!