Web Server

Discussions on extending SharpCap using the built in Python scripting functionality
metastable
Posts: 45
Joined: Thu Oct 26, 2023 1:24 am

Re: Web Server

#21

Post by metastable »

I'm making steady progress but haven't gotten to the point where I can start doing polar alignment. I have a couple questions at this moment. I'm looking to use

Code: Select all

SharpCap.SelectedCamera.SaveAsViewed
Because I've noticed that simply capturing a frame and sending that over is the bayered image without stretching and I'm trying to avoid doing image manipulation on the small client I'm building. My first question is how do I call that function? It requires an object with the interface IFileNameProvider but I can't figure out how to get any more information on what the interface requires.

I've also been considering your suggestion of writing a dll in c# and then calling into, which I'm not against, but would there be a way to import the SharpCap signatures so that I could call into them and get intellisense within my editor? I did a little digging into the SharpCap.dll but it looks like you'd prefer people not get into SharpCap.App.dll, so I stopped digging after that.

Here's a screenshot of the current state of the app. You can see the bayer issue =]
Screenshot 2023-11-12 085230.png
Screenshot 2023-11-12 085230.png (410.98 KiB) Viewed 8684 times
User avatar
admin
Site Admin
Posts: 13022
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Web Server

#22

Post by admin »

Hi,

yes, you are right that I don't really want people picking over the code of SharpCap - as a commercial product I have to have some level of protection against reverse engineering and plagiarism. That does currently mean that there is no good way to get hold of a referenceable assembly to use in C# development. I'm not sure how easy that would be to change as I do have an assembly that contain the public interfaces of the various objects, but it's currently embedded rather than installed as a file. I will have to think a bit about that one.

On the debayering front, it's probably easiest if I add an overload of the SaveAsViewed method that takes a filename to save to - should only be about 3 lines of code :)

cheers,

Robin
metastable
Posts: 45
Joined: Thu Oct 26, 2023 1:24 am

Re: Web Server

#23

Post by metastable »

Understandable! It's not a big deal if I can't rebuild the server in C#, I'm getting some much-needed practice in Python :lol:.

That would be great. I'm looking forward to the next update!
metastable
Posts: 45
Joined: Thu Oct 26, 2023 1:24 am

Re: Web Server

#24

Post by metastable »

Thanks to your recent update I've managed to make a good bit of progress. I can now start the polar alignment process but noticed if it thinks it's been rotated it forces me to restart the process but doing so seems to cause the auto advance to deselect which means I need to remote into the device anyways. Is it possible to navigate the UI through code? It would be nice to be able to also go through the flat and dark capture process, but I don't believe that's doable without UI interaction.

Anyways, here's what it looks like so far.
Attachments
Screenshot_20231114-212357.jpg
Screenshot_20231114-212357.jpg (620.64 KiB) Viewed 8626 times
User avatar
admin
Site Admin
Posts: 13022
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Web Server

#25

Post by admin »

Hi,

there's no current way to navigate the UI through the Python scripting or through the sequencer, and that's something that isn't likely to happen either (too complex and/or introduces reverse dependencies in the code, which is messy). Is the issue that you are rotating and don't know when the auto-advance happens, so you keep on rotating too long and that gets picked up?

As to darks and flats, you can schedule those for capture via the sequencer tool, and you can launch sequences from scripting, so there is a workaround there.

cheers,

Robin
metastable
Posts: 45
Joined: Thu Oct 26, 2023 1:24 am

Re: Web Server

#26

Post by metastable »

Okay no worries on the UI stuff. Yes, that seems to happen to me quite a bit. I've also had instances where in the middle of adjusting my alignment it thinks I've rotated but usually if I wait a few frames, it seems happy to continue. I think it might be due to my image stretch.

I'll investigate how to use to sequencer and assign that to the preprocessing.

Thanks!
metastable
Posts: 45
Joined: Thu Oct 26, 2023 1:24 am

Re: Web Server

#27

Post by metastable »

I've managed to get the Darks and Flats flow into separate sequences and am now able to trigger their running from my app but I've hit another snag. It seems running the sequence with `SharpCap.Sequencer.RunSequenceFile` runs synchronously which means when I'm taking Darks the HTTP connection ends up timing out. I've attempted to run the function within a Task but it seems to not like that and gives me weird behaviours. Any ideas?
User avatar
admin
Site Admin
Posts: 13022
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Web Server

#28

Post by admin »

Hi,

yes, currently the calls to run the sequencer from scripting are synchronous. That's really a reliability thing, because if you try to run an async method and get waiting for it wrong then you can deadlock the application quite easily. You need to wait a little bit, pump messages, repeat until the task is complete.

Could you kick off the sequencer code in a separate thread? That should work I think.

cheers,

Robin
metastable
Posts: 45
Joined: Thu Oct 26, 2023 1:24 am

Re: Web Server

#29

Post by metastable »

I just tested this out with `Thread(ThreadStart(lamda : SharpCap.Sequencer.RunSequenceFile(<my_sequence_path>)))` and it gave me an error prompt that it could not parse the sequence file, this is the same file that's run previously without issue, and after I cleared the prompt SharpCap proceeded to close down. I'm still getting familiar with IronPython, is this the way to run a thread in this case?
User avatar
admin
Site Admin
Posts: 13022
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Web Server

#30

Post by admin »

Hi,

odd, this works for me

Code: Select all

import time
clr.AddReference("System.Threading")
from System.Threading import Thread
from System.Threading import ThreadStart
threadstart = ThreadStart(lambda : SharpCap.Sequencer.RunSequenceFile("c:\\users\\robin\\desktop\\pause.scs"))
thread = Thread(threadstart)
thread.Start()
print (thread.IsAlive)
time.sleep(9)
print (thread.IsAlive)
time.sleep(2)
print (thread.IsAlive)
time.sleep(2)
print (thread.IsAlive)
My sequence is very simple - just a delay of 10 seconds, so perhaps a more complex sequence will break it? Let me know what you find out.

cheers,

Robin
Post Reply