I want to be able to change some camera settings with a Python script. I ran this program on a remote Raspberry Pi Zero by SSHing to it. It runs to completion without error, ok but nothing happens. Here's what I tried:

170 views
Skip to first unread message

Allen Arnold

unread,
Mar 11, 2021, 7:44:27 PM3/11/21
to motioneye
import time
import subprocess
import picamera
subprocess.call (["killall,"motion"])
with picamera.PiCamera() as camera:
     camera.start_preview()
     if <condition> = true:
          camera.brightness = 100
     time.sleep(5)
     camera.stop_preview()


Kevin Shumaker

unread,
Mar 12, 2021, 7:02:55 AM3/12/21
to Allen Arnold, motioneye
Missing a quote (probably a typo putting it here)
subprocess.call (["killall,"motion"])
Is this python 2.7 or 3.x?
Are you calling it with python3 script.py or python2 script.py?
If being called programmatically, does the user doing the call have permissions?
Add a shebang line to the top of the script:
  • #!/usr/bin/env python  (or python2 if your default is python3 and it's a python2 script, or vice-versa)
  • Mark the script as executable:
  • chmod +x myscript.py




--
You received this message because you are subscribed to the Google Groups "motioneye" group.
To unsubscribe from this group and stop receiving emails from it, send an email to motioneye+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/motioneye/f00ed1f8-0bab-49ab-9707-d2bff53de4a0n%40googlegroups.com.


--
Thanks

Kevin Shumaker


N38° 19' 56.52"
W85° 45' 8.56"

Semper Gumby
“Don't tell people how to do things. Tell them what to do and let them surprise you with their results.” - G.S. Patton, Gen. USA
Ethics are what we do when no one else is looking.
Quis custodiet ipsos custodes?
“There is no end to the good you can do if you don’t care who gets the credit.” - C Powell
You know we're sitting on four million pounds of fuel, one nuclear weapon and a thing that has 270,000 moving parts built by the lowest bidder. Makes you feel good, doesn't it?

Allen Arnold

unread,
Mar 12, 2021, 10:20:33 AM3/12/21
to motioneye
Hi Kevin,
Thanks for your suggestions. I tried it, but the same thing happens. Program executes to completion without errors, but brightness is not changed. I am running this script on a remote, headless Pi Zero W with Python 2.7 and with MotionEye running. I used the call (["killall","motion"]) to stop camera processing while I run my script. Without it, the program bombs, I think because you cant run two camera processes at the same time. Maybe MotionEye's config file overides my program. I also read that some camera parms only change the "preview" and not the saved pictures, and vice versa. Maybe I should take out the start_preview line. I'll try that. Finally, is it possible that you just cant change camera parms while MotionEye runs? If so, I know I can use sed to edit the MotionEye config file directly to change the camera parms, but I didn't want to do it that way. Any ideas are gratefully welcomed.
Sincerely,
Allen Arnold

Kevin Shumaker

unread,
Mar 12, 2021, 10:44:37 AM3/12/21
to Allen Arnold, motioneye
motion and motionEye when restarted would re-read their config files and override whatever you changed.
A work-around would be to create 2 copies of the config file, one with the regular settings, one with your modifications.,
and shut down motionEye, and rename motion.conf,std to motion.conf and restart motionEye.
Then to turn on your settings, shut down motionEye, and rename moton.conf.mine to motion.conf and restart.
,

Allen Arnold

unread,
Mar 12, 2021, 9:52:14 PM3/12/21
to motioneye
Kevin,
i'm doing a variation of your idea and it worked. You were right that MotionEye overwrites any camera parm changes when it starts because it reads the config files. I have at least four conditions I'm testing so I needed four copies of the config file (camera-1.conf1, camera-1.conf2, etc), each with my modifications. Based on the test, i just copy camera-1.confx to camera-1.conf and restart MotionEye to re-read the config file. Unfortunately, it takes more time than I'd like. I wonder if there's a way to force MotionEye to read the config file without shutting down and restarting. That would probably be faster. Anyway, your idea is much easier than dealing with the crazy syntax of the sed command. Thanks much for your help!

Allen

Kevin Shumaker

unread,
Mar 13, 2021, 5:33:13 AM3/13/21
to Allen Arnold, motioneye
instead of:
stop motioneye
copy
start motioneye
did you try
copy
systemctl motioneye restart?
THere are needed delays built in while it starts up each camera and I am not sure if there is a way to bypass the delays
systemctl reload motioneye gave an error, but works with other services...


Reply all
Reply to author
Forward
0 new messages