Using digiCamControl as a standalone library

lokatz
Posts: 9
Joined: Fri Aug 19, 2016 9:50 am

Using digiCamControl as a standalone library

Post by lokatz » Fri Sep 09, 2016 5:29 pm

Your solution is very powerful but also complex when trying to use it as a standalone library. I'm looking to use it with my own WPF UI (only for Nikon DSLRs) but am struggling to get started. I admit I am not very experienced with C#, which doesn't help. The CameraControl.Devices.Example sample code helps with Capture and LiveView but unfortunately does not give clues how to access other camera parameters and events. Appreciate any guidance here, especially on these two questions:

1. How can I detect and respond to camera events, such as changes in shutter speed or ISO settings done right on the camera itself, without binding WPF controls to PropertyChangedNotifiers? Say, the user changes the JPEG compression level on the camera from Fine to Normal: I assume the camera would send a CONST_PROP_CompressionLevel notification - but how can I catch it? Is there an event notifier method I could hook into? How would I do that?

2. In trying to connect to a Nikon camera with a WU-1A WiFi adapter, I looked at what you did in GetIpWnd and tried to extract what I need to connect directly to my camera. I thought I could simply compress it to this:

Code: Select all

 try
    {
        IWifiDeviceProvider wifiDeviceProvider;
        ServiceProvider.DeviceManager.AddDevice(wifiDeviceProvider.Connect("192.168.1.1"));
    }
    catch (Exception exception)
    {
        Log.Error("Unable to connect to WiFi device", exception);

    }
but that doesn't work because wifiDeviceProvider.Connect is null. How do I need to instantiate it? It seems ServiceProvider.DeviceManager.WifiDeviceProviders is a list holding all available wireless connections, so I thought about using that one but found it was also empty.

Using digiCamControl as a standalone library

Advertisment
 

BStrauss3
Posts: 36
Joined: Sun Jun 12, 2016 11:12 pm

Re: Using digiCamControl as a standalone library

Post by BStrauss3 » Mon Sep 12, 2016 6:34 pm

Take a look at the remote program (although Dukus doesn't love it, it works) - it's a minimal shell around the library

lokatz
Posts: 9
Joined: Fri Aug 19, 2016 9:50 am

Re: Using digiCamControl as a standalone library

Post by lokatz » Tue Sep 13, 2016 1:46 pm

I assume you're referring to CameraControlRemoteCmd ? Will do, thanks!

EDIT: Having looked at it, I guess that's not the one...

BStrauss3
Posts: 36
Joined: Sun Jun 12, 2016 11:12 pm

Re: Using digiCamControl as a standalone library

Post by BStrauss3 » Tue Sep 13, 2016 2:23 pm

Camera Control cmd not remote cmd... (that one is just a shell sending commands to the gui),

Now depending on the specifics of your need, there is still a lot of complexity, in part due to supporting multiple camera and brands and trying to abstract this. For example Canon requires that certain functions - e.g. capture - be performed in a separate thread, so dccCmd creates the thread to call the Canon DLL, the transfer of the image is async so that adds to the complexity.

So if you don't need this, it's a lot easier to join Canon's free developer program, download the DLL and docs and roll your own code.

I assume Nikon has a similar setup. I know from looking at the dccCmd code that there are a number of Nikon families where the under-the-covers implementation of the features differs.

lokatz
Posts: 9
Joined: Fri Aug 19, 2016 9:50 am

Re: Using digiCamControl as a standalone library

Post by lokatz » Tue Sep 13, 2016 3:16 pm

Thanks, will sink my teeth into it. My focus is solely on Nikons and I already understand their control logic quite well, but that's from Nikon's SDK which does not support WiFi. I'm also looking to support only a single camera, so my issue is accessing the first Nikon I can find wirelessly and identifying&responding to its events.


EDIT: Having tested and run CameraControlCmd a few times, I can see why Duka doesn't like it. It crashed my PC more than once, and royally so. ;)

Anyway, looking at this code has been helpful for me as I finally figured out how to set camera properties, and I appreciate your willingness to help. My two initial issues remain confusing for me, though (please forgive my ignorance if I overlooked the obvious): the only related event handler I could find was in the line

Code: Select all

StaticHelper.Instance.PropertyChanged += Instance_PropertyChanged;

I hooked up the corresponding handler in my program but it never triggered, no matter what changes I made camera-side. Looking at other options, I noticed that CameraDeviceManager has a NotifyPropertyChanged method but so far couldn't figure out how to hook into it.

I also did not find any reference in CameraControlCmd to connecting the camera wirelessly. What am I missing?

Duka Istvan
Posts: 684
Joined: Sat Oct 03, 2015 7:57 pm

Re: Using digiCamControl as a standalone library

Post by Duka Istvan » Thu Sep 15, 2016 10:39 pm

For wifi try this :

Code: Select all

            try
            {
                IWifiDeviceProvider wifiDeviceProvider = new PtpIpProvider();
                DeviceManager.AddDevice(wifiDeviceProvider.Connect("192.168.1.1"));
            }
            catch (Exception exception)
            {
                MessageBox.Show("Unable to connect to WiFi device " + exception.Message);
            }


Duka Istvan
Posts: 684
Joined: Sat Oct 03, 2015 7:57 pm

Re: Using digiCamControl as a standalone library

Post by Duka Istvan » Thu Sep 15, 2016 10:56 pm

Unfortunately no option to detect if a camera property was changed or not

lokatz
Posts: 9
Joined: Fri Aug 19, 2016 9:50 am

Re: Using digiCamControl as a standalone library

Post by lokatz » Thu Sep 15, 2016 11:06 pm

Thanks a lot for the Wifi hint! I just implemented the change, but unfortunately it still shows the exception error. I traced the method calls in VisualStudio and found that the exception gets thrown in this code (in CameraDeviceManagers.cs):

Code: Select all

public static Type GetNativeDriver(string model)
        {
            if (String.IsNullOrEmpty(model))
                return null;
            // first check if driver exist with same driver name
            if (DeviceClass.ContainsKey(model))
                return DeviceClass[model];
            return null;
            //// in driver not found will check with regex name
            //return (from keyValuePair in DeviceClass
            //        let regex = new Regex(keyValuePair.Key)
            //        where regex.IsMatch(model)
            //        select keyValuePair.Value).FirstOrDefault();
        }
The line throwing the error is "if (DeviceClass.ContainsKey(model))". The value of model is "D7100", which is the correct code for my Nikon camera, and the whole thing works smoothly when the same camera is connected via USB. Any idea what may be happening here?

No need for an immediate reply, by the way. I know you're pretty busy and can wait until you find the time for my two issues. Appreciate your (and BStrauss3's) willingness to help.


EDIT: (Should have checked this, as well.) I just realized that DeviceClass is null, which explains the exception. I am calling the Wifi initialization after this code executed, so I assume there's something else I need to initialize:

Code: Select all

            ServiceProvider.Branding = Branding.LoadBranding();
            ServiceProvider.ConfigureDatabase();
            ServiceProvider.Settings = new Settings();
            ServiceProvider.Settings = ServiceProvider.Settings.Load();
            ServiceProvider.Settings.LoadSessionData();
            ServiceProvider.WindowsManager = new WindowsManager();

            DeviceManager = new CameraDeviceManager();
            DeviceManager.CameraSelected += DeviceManager_CameraSelected;
            DeviceManager.CameraConnected += DeviceManager_CameraConnected;
            DeviceManager.PhotoCaptured += DeviceManager_ImageCaptured;
            DeviceManager.CameraDisconnected += DeviceManager_CameraDisconnected;
            DeviceManager.DisableNativeDrivers = false;
            
            InitializeComponent();

Duka Istvan
Posts: 684
Joined: Sat Oct 03, 2015 7:57 pm

Re: Using digiCamControl as a standalone library

Post by Duka Istvan » Fri Sep 16, 2016 10:15 am

Maybe the wifi connection not working ... Do you managed to make a connection using digiCamControl ?

lokatz
Posts: 9
Joined: Fri Aug 19, 2016 9:50 am

Re: Using digiCamControl as a standalone library

Post by lokatz » Fri Sep 16, 2016 10:54 am

Yes, it works fine with digiCamControl - just tested it again.

Post Reply