I installed and have running the google home + raspberry pi from: http://www.instructables.com/id/Google-Home-Raspberry-Pi-Power-Strip/ I modified the sw1_on.py and sw1_off.py codes to turn on an led light instead of the relays and got it working perfect. I need it however, to activate a opencv script instead for a school project I am working on. I copied all of the necessary files for the opencv project (the .prototxt.txt and .caffemodel files) as well as the code into the same directory as the sw1_on.py and sw1_off.py. I then made a copy of my opencv code and named them both sw1_on.py and sw1_off.py (and renamed the original sw1_on.py and sw1_off.py to something else) so that anytime I made a POST request it would run the same opencv code. But when i run the POST request it won't activate the opencv script. I can run the open cv code perfectly from terminal and can run the led code from a POST request perfectly as well. I'm not sure why it won't activate the opencv code.
Here are the permissions:
-rwxr-xr-x 1 pi pi 4623 Feb 5 15:28 I2C_LCD_driver.py
-rw-r--r-- 1 pi pi 66840 May 1 2012 i2c-tools_3.1.0.orig.tar.bz2
-rw-r--r-- 1 pi pi 23147564 Jan 28 18:34 MobileNetSSD_deploy.caffemodel
-rw-r--r-- 1 pi pi 29353 Jan 28 18:33 MobileNetSSD_deploy.prototxt.txt
-rw-r--r-- 1 pi pi 1247 Feb 16 19:45 motors.py
drwxr-xr-x 2 pi pi 4096 Feb 19 16:16 __pycache__
-rw-r--r-- 1 pi pi 859 Jan 28 18:33 results.txt
-rw-r--r-- 1 pi pi 182 Feb 16 14:07 sw1_offLIGHT.py
-rw-r--r-- 1 pi pi 5253 Feb 19 16:19 sw1_off.py
-rw-r--r-- 1 pi pi 168 Feb 16 14:07 sw1_onLIGHT.py
-rw-r--r-- 1 pi pi 5255 Feb 19 16:38 sw1_on.py
Below is the beginning of my opencv code. For further inspection I put the lcd screen at the bottom and tested if the code would run all the way to it. I found that the commented out portions stopped the code from reaching the lcd screen. But when they were commented out (like now) the code ran fine all the way down to the lcd screen
#from imutils.video import VideoStream
#from imutils.video import FPS
#import imutils
import I2C_LCD_driver
import time
import cv2
import argparse
import numpy as np
ap = argparse.ArgumentParser()
ap.add_argument("-c", "--confidence", type=float, default = 0.2,
help="minimum probability to filter weak detections")
args = vars(ap.parse_args())
CLASSES = ["background", "aeroplane", "bicycle", "bird", "boat",
"bottle", "bus", "car", "cat", "chair", "cow", "diningtable",
"dog", "horse", "motorbike", "person", "pottedplant", "sheep",
"sofa", "train", "tvmonitor"]
COLOR = np.random.uniform(0, 255, size=(len(CLASSES), 3))
#net = cv2.dnn.readNetFromCaffe('MobileNetSSD_deploy.prototxt.txt','MobileNetSSD_deploy.caffemodel')
mylcd = I2C_LCD_driver.lcd()
mylcd.lcd_display_string("Initiating", 1, 0)
mylcd.lcd_display_string("Program", 2, 0)
The place where i'm having trouble getting rid of imutils is right after it reads an image frame:
frame = imutils.resize(frame, width = 400)
(h, w) = frame.shape[:2]
I've tried
frame = cv2.resize(frame, (400, 300))
But that throws an error. However I'm probably using it wrong