How to initialize the camera properly?

Post Reply
fran@servifot.com
Posts: 10
Joined: Fri Jun 22, 2018 3:44 pm

How to initialize the camera properly?

Post by fran@servifot.com » Mon Oct 29, 2018 1:50 pm

Hi all.

After a time working with DigicamControl Source Code. I've developed a simple app to take photos with an interface, something like a photo Booth.

I made all my tests with a Canon EOS 1300, and everything worked correctly.

But now I've tried the Canon EOS 4000, and the live view doesn't work, when I use the Function StartLiveView() an exception is thrown.
Methow who throws the exception:

Code: Select all

	public static void Assert(uint result, string message)
        {
            if (Util.HasFailed(result))
                throw new EosException(result, message);
        }
Exception:
Canon.Eos.Framework.EosException: 'Failed to open session.'
Well, this could be an incompatibility of versions or something like that, BUT! If I execute CameraControl base Project, the live view works PERFECTLY! :shock: :shock:

That's why I suppose that I'm missing something when I initialize the camera.

Reading Code, and looking for the initialize method i've found that DigicamControl initialize the camera here:
App.xaml.cs

Code: Select all

// event handlers
ServiceProvider.Settings.SessionSelected += Settings_SessionSelected;

ServiceProvider.DeviceManager.CameraConnected += DeviceManager_CameraConnected;
ServiceProvider.DeviceManager.CameraSelected += DeviceManager_CameraSelected;
ServiceProvider.DeviceManager.CameraDisconnected += DeviceManager_CameraDisconnected;
//-------------------
ServiceProvider.DeviceManager.DisableNativeDrivers = ServiceProvider.Settings.DisableNativeDrivers;
if (ServiceProvider.Settings.AddFakeCamera)
    ServiceProvider.DeviceManager.AddFakeCamera();
ServiceProvider.DeviceManager.LoadWiaDevices = ServiceProvider.Settings.WiaDeviceSupport;
ServiceProvider.DeviceManager.DetectWebcams = ServiceProvider.Settings.WebcamSupport;
ServiceProvider.DeviceManager.ConnectToCamera();
if (ServiceProvider.Settings.DisableHardwareAccelerationNew)
    OpenCL.IsEnabled = false;
And that's what I do for Initialize the camera:

Code: Select all

public void InitCamera()
        {
            DeviceManager = new CameraDeviceManager();
            DeviceManager.UseExperimentalDrivers = true;
            DeviceManager.CameraConnected += DeviceManager_CameraConnected;
            DeviceManager.CameraDisconnected += DeviceManager_CameraDisconnected;
            DeviceManager.PhotoCaptured += DeviceManager_PhotoCaptured;

            DeviceManager.DisableNativeDrivers = false;
            DeviceManager.LoadWiaDevices = true;
            DeviceManager.DetectWebcams = true;

            Available = DeviceManager.ConnectToCamera();
            if (Available)
            {
                EmitConected("Conectado a alguna cámara");
                Console.WriteLine("Conectado a alguna cámara");
            }
            else
            {
                EmitError("No hay ninguna cámara :(");
            }

            if (DeviceManager.SelectedCameraDevice != null && DeviceManager.SelectedCameraDevice.DeviceName != null)
            {
                if (!DeviceManager.SelectedCameraDevice.DeviceName.ToLower().Contains("canon"))
                {
                    for (int i = 0; i < 3 && !DeviceManager.SelectedCameraDevice.DeviceName.ToLower().Contains("canon"); i++)
                    {
                        DeviceManager.SelectNextCamera();
                    }
                }

                Available = true;
                ICameraDevice cameraDevice = DeviceManager.SelectedCameraDevice;
                EmitConected("¡Se ha conectado una cámara!");
                Console.WriteLine("Camera conected: " + cameraDevice.DeviceName);
                cameraDevice.CaptureCompleted += CameraDevice_CaptureCompleted;
            }
            else
            {
                EmitError("No se ha podido conectar a ninguna cámara :(");
            }
        }
Am I missing something? I'm quite desperate, so any help would be infinitely thanked.

If it is important, I initialize the live view just with this function:
DeviceManager.SelectedCameraDevice.StartLiveView();

How to initialize the camera properly?

Advertisment
 

ToadJoey
Posts: 2
Joined: Fri Nov 09, 2018 12:07 pm

Re: How to initialize the camera properly?

Post by ToadJoey » Fri Nov 09, 2018 12:11 pm

I've got the exact same problem with my Nikon D5100. We are using the code for the exact same purpose, a simple photobooth app.

When i first try to run the Liveview i get a 'Invalid status' exception. But when run the DigiCamControl program and start the Liveview it just runs. If i get back to my application then it also runs.

It looks like the DigiCamControl program sets the camera in a different mode.

Curious if you found the solution to this problem? Really freaking me out for a month now :lol:

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

Re: How to initialize the camera properly?

Post by Duka Istvan » Sun Nov 11, 2018 11:30 am

You should call before start the live view the GetProhibitionCondition(OperationEnum.LiveView) function to get the possible error cause

fran@servifot.com
Posts: 10
Joined: Fri Jun 22, 2018 3:44 pm

Re: How to initialize the camera properly?

Post by fran@servifot.com » Mon Nov 12, 2018 10:02 am

Hi All.

Thanks for the reply!

I've tried GetProhibitionCondition(OperationEnum.LiveView) with Canon EOS 4000 like

Code: Select all

DeviceManager.SelectedCameraDevice.GetProhibitionCondition(OperationEnum.LiveView)
But it returns a blank string ""...

¿What could I test?

I really need that my program works as yours that never fails. :?

I'm probably missing an important function before starting the liveview or after init the camera.

¿Any suggestion?

Thanks in advance.

fran@servifot.com
Posts: 10
Joined: Fri Jun 22, 2018 3:44 pm

Re: How to initialize the camera properly?

Post by fran@servifot.com » Mon Nov 12, 2018 10:36 am

Ok.

I've tested more things.
I thought that It was just the LiveView but no.

I can't take a photo.
I get some errors:
'Canon.Eos.Framework.EosPropertyException' en Canon.Eos.Framework.dll
'Canon.Eos.Framework.EosPropertyException' en Canon.Eos.Framework.dll
'Canon.Eos.Framework.EosException' en Canon.Eos.Framework.dll
'Canon.Eos.Framework.EosException' en CameraControl.Devices.dll
Canon.Eos.Framework.EosPropertyException: Comm Disconnected.
Failed to get property integer data: propertyId 1281
en Canon.Eos.Framework.Helper.Util.Assert(UInt32 result, String message, UInt32 propertyId, Object propertyValue) en C:\Users\SERVIFOT\source\repos\digiCamControl-master\Canon.Eos.Framework\Helper\Util.cs:línea 40
en Canon.Eos.Framework.EosObject.<>c__DisplayClass28_0.<GetPropertyIntegerData>b__0() en C:\Users\SERVIFOT\source\repos\digiCamControl-master\Canon.Eos.Framework\EosObject.cs:línea 179
en Canon.Eos.Framework.EosObject.ExecuteGetter[TResult](Func`1 function) en C:\Users\SERVIFOT\source\repos\digiCamControl-master\Canon.Eos.Framework\EosObject.cs:línea 127
en Canon.Eos.Framework.EosCamera.ExecuteGetter[TResult](Func`1 function) en C:\Users\SERVIFOT\source\repos\digiCamControl-master\Canon.Eos.Framework\EosCamera.cs:línea 310
Canon.Eos.Framework.EosPropertyException: Comm Disconnected.
Failed to get property string data: propertyId 2
en Canon.Eos.Framework.Helper.Util.Assert(UInt32 result, String message, UInt32 propertyId, Object propertyValue) en C:\Users\SERVIFOT\source\repos\digiCamControl-master\Canon.Eos.Framework\Helper\Util.cs:línea 40
en Canon.Eos.Framework.EosObject.<>c__DisplayClass33_0.<GetPropertyStringData>b__0() en C:\Users\SERVIFOT\source\repos\digiCamControl-master\Canon.Eos.Framework\EosObject.cs:línea 230
en Canon.Eos.Framework.EosObject.ExecuteGetter[TResult](Func`1 function) en C:\Users\SERVIFOT\source\repos\digiCamControl-master\Canon.Eos.Framework\EosObject.cs:línea 127
en Canon.Eos.Framework.EosCamera.ExecuteGetter[TResult](Func`1 function) en C:\Users\SERVIFOT\source\repos\digiCamControl-master\Canon.Eos.Framework\EosCamera.cs:línea 310
Fallo Not Supported.
Failed to open session.
But with your program, all works perfectly.

I don't understand why... :cry: :cry: :cry:

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

Re: How to initialize the camera properly?

Post by Duka Istvan » Mon Nov 12, 2018 11:06 am

The ' Comm Disconnected.' message suggest that the camera isn't recognized. Try to use the latest Canon camera SDK files EDSDK.dll , EdsImage.dll (copy it manually to the executable folder)

fran@servifot.com
Posts: 10
Joined: Fri Jun 22, 2018 3:44 pm

Re: How to initialize the camera properly?

Post by fran@servifot.com » Mon Nov 12, 2018 11:31 am

Thank you so much!!

That was exactly my problem. I don't know how I was using different DLL than the Main project.
I've changed them and now it works perfectly.

You've answered really quickly, thank you!

This project is awesome, and as soon as I finish our project I'll try to support you.

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

Re: How to initialize the camera properly?

Post by Duka Istvan » Mon Nov 12, 2018 11:41 am

Thanks for the feedback


Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests