You have to change/remove username:password on what you have saved on your camera interface for user access.
Also <DEVICEID> is the idx of percentage sensor.
You will also install imagemagick.
The mechanism is to resize image to 1 pixel and measure the percentage of light on this pixel.
credits go here: https://matdomotique.wordpress.com/2016 ... camera-ip/
Code: Select all
import os, sys import requests from subprocess import Popen, PIPE process = Popen(['wget','-O','/home/pi/shot'+'cam'+'.jpg','http://username:[email protected]'+'/image/jpeg.cgi'], stdout=PIPE) (output, err) = process.communicate() exit_code = process.wait() process = Popen(["convert /home/pi/shot"+'cam'+".jpg -colorspace hsb -resize 1x1 txt: | grep \",*%)\" | cut -f 6 -d ',' | cut -c -5"], stdout=PIPE, shell=True) (output, err) = process.communicate() exit_code = process.wait() value = str(output).replace('\n','') url = 'http://127.0.0.1:8080/json.htm?type=command¶m=udevice&idx=<DEVICEID>&nvalue=0&svalue=' + value r = requests.get(url)