This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# USAGE | |
# python detect_shapes.py --image shapes_and_colors.png | |
# import the necessary packages | |
from pyimagesearch.shapedetector import ShapeDetector | |
import argparse | |
import imutils | |
import cv2 | |
# construct the argument parse and parse the arguments |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Import modules | |
import picamera | |
import picamera.array | |
import time | |
import cv2 | |
import numpy as np | |
#Initialize camera | |
camera = picamera.PiCamera() | |
camera.resolution = (640,480) | |
rawCapture = picamera.array.PiRGBArray(camera) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from picamera.array import PiRGBArray | |
from picamera import PiCamera | |
import time | |
import cv2 | |
import sys | |
import imutils | |
# Get user supplied values | |
cascPath = sys.argv[1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import cv2 | |
img1 = cv2.imread('rasp1.png') | |
h,w,bpp = np.shape(img1) | |
img_gray = cv2.cvtColor(img1,cv2.COLOR_BGR2GRAY) | |
img2=cv2.merge((img_gray,img_gray,img_gray)) | |
th1, img3 = cv2.threshold(img2, 127, 255, cv2.THRESH_BINARY) | |
img4 = cv2.resize(img1,None,fx=0.1, fy=0.1, interpolation = cv2.INTER_AREA) | |
img4 = cv2.resize(img4,None,fx=10, fy=10, interpolation = cv2.INTER_AREA) | |
img5 = cv2.GaussianBlur(img1,(9,9),10) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import picamera | |
with picamera.PiCamera() as camera: | |
camera.resolution = (640, 480) | |
camera.start_recording('my_video.h264') | |
camera.wait_recording(10) | |
camera.stop_recording() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import picamera | |
with picamera.PiCamera() as camera: | |
camera.resolution = (1024, 768) | |
camera.start_preview() | |
# Camera warm-up time | |
time.sleep(2) | |
camera.capture('my_image.jpg') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import paho.mqtt.client as paho | |
broker="192.168.xx.xx" #IP of your Raspberry Pi | |
#define callback | |
def on_message(client, userdata, message): | |
print("received message =",str(message.payload.decode("utf-8"))) | |
client= paho.Client("client-001") | |
client.on_message=on_message |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ESP8266WiFi.h> | |
#include <PubSubClient.h> | |
const char* ssid = "YOUR_SSID"; | |
const char* password = "YOUR_PASSWORD"; | |
const char* mqtt_server = "192.168.XX.XXX";// Your Raspberry Pi IP address | |
WiFiClient espClient; | |
PubSubClient client(espClient); | |
long lastMsg = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RPi.GPIO as IO | |
from time import sleep | |
IO.setwarnings(False) | |
IO.setmode(IO.BOARD) | |
IO.setup(11,IO.OUT) | |
IO.setup(12,IO.OUT) | |
IO.setup(13,IO.OUT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RPi.GPIO as IO | |
from time import sleep | |
IO.setwarnings(False) | |
IO.setmode(IO.BOARD) | |
IO.setup(7,IO.IN) | |
print("Reading IR sensor. Ctrl+C to quit") | |
while 1: | |
if(IO.input(7)==True): |