Integrating JSON and Python Files into CodeProject.AI for Blue Iris #273
MMarea
started this conversation in
Show and tell
Replies: 1 comment
-
Hi, did you get this working? I have a similar use case. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I hope your assistance with a project I am currently working on. I have developed two files: one JSON configuration file and one Python script. My goal is to combine these files into a single project and install it as a module on CodeProject.AI to be used with Blue Iris software.
Here are the details of the files:
JSON Configuration File: This file contains the necessary settings for connecting to the Blue Iris server, specifying the camera, and defining the detection and alert parameters.
Python Script: This script processes the camera feed from Blue Iris, detects the blinking light, and sends an email alert when the light switches from green to red.
I would greatly appreciate your guidance on how to properly combine these files and integrate them as a module into the CodeProject.AI server.
JSON code:
{
"blueIris": {
"server": "#######",
"user": "local_console",
"password": "###",
"camera": "My Camera 15"
},
"detection": {
"type": "blink",
"color": "green",
"switchColor": "red",
"alert": {
"method": "email",
"email": {
"to": "#####@gmail.com",
"subject": "Alert: Light switched from green to red",
"body": "The monitored light has switched from blinking green to blinking red."
}
}
}
}
py code:
import cv2
import json
import smtplib
from email.mime.text import MIMEText
Load configuration
with open('light_detection_config.json', 'r') as f:
config = json.load(f)
Set up camera feed
camera_url = config['blueIris']['server'] + '/path_to_camera_feed'
cap = cv2.VideoCapture(camera_url)
Function to send email
def send_email(subject, body, recipient):
msg = MIMEText(body)
msg['Subject'] = subject
msg['From'] = '######'
msg['To'] = recipient
with smtplib.SMTP('smtp.gmail.com') as server:
server.login('#####@gmail.com', '######')
server.sendmail('#####@gmail.com', [recipient], msg.as_string())
Detection loop
while True:
ret, frame = cap.read()
if not ret:
break
cap.release()
cv2.destroyAllWindows()
Beta Was this translation helpful? Give feedback.
All reactions