My custom ASCOM driver for Sony cameras

Post Reply
axlns
Posts: 4
Joined: Mon Sep 30, 2019 5:48 pm

My custom ASCOM driver for Sony cameras

#1

Post by axlns »

Hello.

This is going to be a question for the SharpCap author mainly. Robin, hopefully you'll find time to read and answer it as the text below is somewhat long :)

First let me describe how I ended up with the issue I'm having now...

Its known that Sony do not have public API to control their cameras remotely, so that makes usage of Sony cameras for more or less automated astrophotograpy quite problematic. The good news is that the guy from CN forum came up with solution, few years ago he wrote small app called MarksAcquisition. The app is "emulating mouse clicks" in the proprietary Sony app called "Imaging Edge", which allows you to control your camera from PC. With the help of this app it is possible to automate taking exposures, and it even can integrate with PHD2 to send dithering commans. The problem is of course that you still cannot use Sony cameras with all of the astrophotography software such as SharpCap (okay, its not entirely true with the Folder monitor camera added, but that requires some additional app which will be taking photos, so its not ideal solution)

So being inspired by MarksAcquisition app and by ASCOM.DSLR driver for Canon and Nikon I decided to write ASCOM camera driver for Sony.
That driver requires you to connect your Sony camera with USB cable and then run Imaging Edge Remote app from sony. The the driver will be "emulating mouse clicks" in Imaging Edge Remote app to take exposures, Imaging Edge Remote app will save those exposures in specified folder, driver will watch that folder, read the files and return back to ASCOM compatible app. So thats the idea. Very close to what you implemented in ASCOM.DSLR driver, but using user32.dll interactions with Sony Imaging Edge app to "talk" to camera instead of public API (which not exists).

Now let me describe the issue itself...

I got this driver working in several ASCOM compatible apps (SGP, PHD2, MaximDL) - they successfully receive image data from my driver. But I'm spending last few days trying to make it working with SharpCap with no luck.

I think I did it all correctly, I tried to return both RGGB data and Color data, but it still not working.

SharpCap giving me error "Cannot convert type 'string' to 'float'" when it tries to process image array returned by my driver.
I'm not sure what the problem is and I cant see anything useful or related to this error in SharpCap logs as well (even with additional logging enabled). I clicked several times that "send and quit" button - https://prnt.sc/pd1nls, so perhaps you already have my logs or at least exception details, but I'll post full stack trace of the error below for your reference.

Can you please help me understand this issue? I have no idea what it tries to convert here. Perhaps you can check your source codes and see what it do not like in the data returned by my driver?

I appreciate your help.

Btw, I'm happy user of SharpCap PRO. I really like the app and the fact that I cant make my driver working with it drives me crazy...

Code: Select all

Microsoft.CSharp.RuntimeBinder.RuntimeBinderException
Cannot convert type 'string' to 'float'
   at CallSite.Target(Closure , CallSite , Object )
   at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
   at SharpCap.Models.Controls.<>c__DisplayClass4_0.<GetValueCached>b__0() in C:\Documents\Source Code\SharpCap3.2\src\SharpCap\Models\Controls.cs:line 41
   at SharpCap.Base.CachedItem`1.GetValue() in C:\Documents\Source Code\SharpCap3.2\src\SharpCap.Base\CachedItem.cs:line 23
   at SharpCap.Models.Controls.GetValueCached(CommonPropertyIDs control) in C:\Documents\Source Code\SharpCap3.2\src\SharpCap\Models\Controls.cs:line 44
   at SharpCap.Models.Camera.OnFrameCaptured(Object sender, FrameCapturedEventArgs e) in C:\Documents\Source Code\SharpCap3.2\src\SharpCap\Models\Camera.cs:line 1263
   at SharpCap.MultiCaptureProvider.Scp_FrameCaptured(Object sender, FrameCapturedEventArgs e) in C:\Documents\Source Code\SharpCap3.2\src\SharpCap\Models\MultiCaptureProvider.cs:line 552
   at SharpCap.Base.CaptureProviderBase`1.OnImageProviderOnFrameCaptured(Object src, FrameCapturedEventArgs args) in C:\Documents\Source Code\SharpCap3.2\src\SharpCap.Base\CaptureProviderBase.cs:line 559
   at SharpCap.Base.BaseImageProvider.OnFrameCaptured(FrameCapturedEventArgs e) in C:\Documents\Source Code\SharpCap3.2\src\SharpCap.Base\BaseImageProvider.cs:line 729
   at SharpCap.Base.BaseImageProvider.ProcessFrame(BufferFrame frame) in C:\Documents\Source Code\SharpCap3.2\src\SharpCap.Base\BaseImageProvider.cs:line 528
   at SharpCap.Base.BaseImageProvider.ProcessThreadProc() in C:\Documents\Source Code\SharpCap3.2\src\SharpCap.Base\BaseImageProvider.cs:line 433
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
Last edited by axlns on Tue Oct 01, 2019 2:50 am, edited 2 times in total.
User avatar
admin
Site Admin
Posts: 13173
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: My custom ASCOM driver for Sony cameras

#2

Post by admin »

Hi,

Good timing on your part – I was just about to publish a new version when I saw your post and fortunately the problem is easy for me to solve. I am assuming from the error that you have implemented gain in your Ascom driver as a list of possible gain values rather than a numeric range. I had a bug in the code that was trying to attach the camera properties to each captured frame object that assumed that the gain would be numeric.

It's easy enough to skip that part of the code in the case that the gain control is a list of possible gain values which should get around this problem although it may mean that the gain doesn't properly show up in the fits headers if you capture to fits files.

Watch out for the next update .

Cheers, Robin
axlns
Posts: 4
Joined: Mon Sep 30, 2019 5:48 pm

Re: My custom ASCOM driver for Sony cameras

#3

Post by axlns »

great! :) waiting for next version then

And yes, you are right, I’m implementing list of possible Gains values (all possible ISO values) in the Camera.Gains array. And my Camera.Gain property holds index of the current Gain in this array.

Based on ASCOM documentation if Gains property returns array, then Gain property should hold index to corresponding Gain value in that Gains array, so you still can get the actual Gain value, by getting it from Camera.Gains[Gain].

Also based on documentation, driver should either implement Gains property or GainMix/GainMax. Should not implement both. If Min/Max implemented then call to Gains should throw NotImplemented exception and vise versa. This is how I designed my driver.
User avatar
admin
Site Admin
Posts: 13173
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: My custom ASCOM driver for Sony cameras

#4

Post by admin »

Hi,

Yes, you're perfectly correct in your handling of gain values – I even support the array list of gains in SharpCap, but somewhere along the way the additional code for recording frame parameters got added without considering that possibility.

Cheers, Robin

PS.new version now available
axlns
Posts: 4
Joined: Mon Sep 30, 2019 5:48 pm

Re: My custom ASCOM driver for Sony cameras

#5

Post by axlns »

Hi Robin,

I can confirm that now my driver works with latest version of SharpCap! I'm happy :) I need to polish a bit my code, create installer project and will release my Sony driver to the community.

Thanks!

Regards, Alex
User avatar
admin
Site Admin
Posts: 13173
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: My custom ASCOM driver for Sony cameras

#6

Post by admin »

Hi Alex,

That's great news! Feel free to post an announcement here in the forums when you are ready for other people to try it out.

Cheers, Robin
axlns
Posts: 4
Joined: Mon Sep 30, 2019 5:48 pm

Re: My custom ASCOM driver for Sony cameras

#7

Post by axlns »

Hi Robin, alpha version of the Sony driver ready - more details on CN - https://www.cloudynights.com/topic/6786 ... or-testing
Thanks for your help!
Post Reply