Hi,
I was trying to understand how to send a command from an Arduino to Sharpcap with the aim to start an image acquisition (ideally each acquired frame should be triggered separately). Could it work by using a COM port?
Ideally I was looking for a tutorial that explains how to read data (eg. a specific character) sent from the Arduino through a COM port in Iron Python, and consequently do an action, but maybe that's too specific.
Sorry for the newbie question, I'm just starting to learn how to use sharpcap and scripting
Thanks in advance!
Davide
Communication between Arduino and SharpCap
- admin
- Site Admin
- Posts: 13483
- Joined: Sat Feb 11, 2017 3:52 pm
- Location: Vale of the White Horse, UK
- Contact:
Re: Communication between Arduino and SharpCap
Hi,
yes, a serial port would be one way to do this - in Iron python you would need some code like this to create a SerialPort object
You can then configure it as required - see https://learn.microsoft.com/en-us/dotne ... mework-4.8 for details on how to configure, open and read from a serial port in .NET (which all translates to IronPython).
For instance
Once you have the port up and running you can take the actions required in response to incoming messages - for instance if you have the camera in still mode in advance then you can use things like
Hope this helps,
Robin
yes, a serial port would be one way to do this - in Iron python you would need some code like this to create a SerialPort object
Code: Select all
clr.AddReference("System")
from System.IO.Ports import SerialPort
sp = SerialPort()
For instance
Code: Select all
sp.PortName = "COM1"
sp.BaudRate = 9600
...
Code: Select all
#Grab a frame from the camera and display it but do not save it
SharpCap.SelectedCamera.BeginFramingShot()
# As above, but also save the frame to an image file
SharpCap.SelectedCamera.CaptureSingleFrame()
Robin
Re: Communication between Arduino and SharpCap
Thanks Robin for your help.
I made a few tries but I still have to learn a bit more on how to code in python.
I will follow your links with more attention and let you know in case I’m in trouble.
Thanks a lot for now.
Davide
I made a few tries but I still have to learn a bit more on how to code in python.
I will follow your links with more attention and let you know in case I’m in trouble.
Thanks a lot for now.
Davide