Newbie needs a bit of help scripting

Discussions on extending SharpCap using the built in Python scripting functionality
Post Reply
Coles44
Posts: 2
Joined: Wed Sep 27, 2023 12:46 am

Newbie needs a bit of help scripting

#1

Post by Coles44 »

Hi,

I am completely new to scripting but experienced in all sorts of imaging. What I would like to do is write a script that tells SharpCap to take X number of frames every X number of minutes and continue this for X number of times or X number of total minutes.

I tried using ChatGBT and that didn't work. Probably because I don't know what I am doing or don't know how to run the script it generated. I put what ChatGBT wrote below.

In any case, I really could use a bit (actually a lot) of help. Thanks in advance.

Eric :-)
---------------------------------

import SharpCap
import time

# Adjust these values as necessary
num_frames = 10
interval_minutes = 2
frame_delay_seconds = 5 # This value may need to be adjusted based on your setup

def capture_frames(num_frames):
for i in range(num_frames):
# Capture a single frame
SharpCap.SelectedCamera.RunCapture(1)
# Wait some time before capturing the next frame (if necessary)
time.sleep(frame_delay_seconds)

# Main loop
while True:
# Capture frames
capture_frames(num_frames)
# Wait for two minutes before capturing the next set of frames
time.sleep(interval_minutes * 60)
User avatar
admin
Site Admin
Posts: 17610
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Newbie needs a bit of help scripting

#2

Post by admin »

Hi Eric,

unless you are set on using the python scripting for some reason that isn't obvious, you might be better using the sequencer tools built into SharpCap 4.0 and 4.1 that make this a lot easier. See https://docs.sharpcap.co.uk/4.0/#The%20 ... e%20Editor (we are still updating the documentation for 4.1).

Otherwise, if you want to use Python, the starting of a new capture is a bit more complex - you need to setup the capture limits and call PrepareToCapture before calling RunCapture.

See viewtopic.php?t=2025 for an example.

cheers,

Robin
Coles44
Posts: 2
Joined: Wed Sep 27, 2023 12:46 am

Re: Newbie needs a bit of help scripting

#3

Post by Coles44 »

Robin,

Thanks, I will check that out. And no, I am not set on python scripting!

Eric
Post Reply