Skip to content

Instantly share code, notes, and snippets.

@flyboy74
flyboy74 / worm.py
Created May 9, 2017 03:22
Worm Class for worm robot
import smbus
import time
class Worm :
global bus
global address
bus = smbus.SMBus(1)
address = 0x40
@flyboy74
flyboy74 / webcam.py
Last active October 7, 2021 15:09
Capture images from webcam stream
import cv2
capture = cv2.VideoCapture(0)
capture.set(3, 320) #set width of frame
capture.set(4, 200) #set hieght of frame
capture.set(5, 20) #set FPS
capture.set(10, 20) #set brightness
successful = True
while successful:
successful, image = capture.read()
@flyboy74
flyboy74 / Follower_CV_4.py
Created March 20, 2017 10:49
Line Follower using computer, remove false positives
from picamera.array import PiRGBArray
from picamera import PiCamera
import time
import cv2
import numpy as np
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(40, GPIO.OUT)
GPIO.output(40, GPIO.HIGH)
@flyboy74
flyboy74 / Follower_colour_intensity.sb
Created March 18, 2017 12:42
Linw Follower with colour and intensity detection
Sensor.SetMode(1,4)
Sensor.SetMode(4,4)
Red_min[0] = 230
Red_min[1] = 40
Red_min[2] = 10
Red_max[0] = 350
Red_max[1] = 90
Red_max[2] = 70
@flyboy74
flyboy74 / Follower_CV_3.py
Created March 17, 2017 03:52
Line Follower using CV detecting angle
from picamera.array import PiRGBArray
from picamera import PiCamera
import time
import cv2
import numpy as np
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(40, GPIO.OUT)
GPIO.output(40, GPIO.HIGH)
@flyboy74
flyboy74 / Follower_greensigns.sb
Created March 16, 2017 12:33
Line Follower that detects green turn signs
Sensor.SetMode(1,4)
Sensor.SetMode(4,4)
Red_min[0] = 230
Red_min[1] = 40
Red_min[2] = 10
Red_max[0] = 350
Red_max[1] = 90
Red_max[2] = 70
@flyboy74
flyboy74 / Follower_cv_2.py
Created March 15, 2017 01:18
Line Follow using CV green sign dection
from picamera.array import PiRGBArray
from picamera import PiCamera
import time
import cv2
import numpy as np
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(40, GPIO.OUT)
GPIO.output(40, GPIO.HIGH)
@flyboy74
flyboy74 / Follower_CV_1.py
Created March 14, 2017 21:54
Line Follower with OpenCV first lesson
from picamera.array import PiRGBArray
from picamera import PiCamera
import time
import cv2
import numpy as np
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(40, GPIO.OUT)
GPIO.output(40, GPIO.HIGH)
@flyboy74
flyboy74 / Colour Detection.sb
Created March 14, 2017 21:51
Colour Detection for Lego EV3 Mindstrom
Sensor.SetMode(1,4)
Sensor.SetMode(4,4)
Red_min[0] = 230
Red_min[1] = 40
Red_min[2] = 10
Red_max[0] = 350
Red_max[1] = 90
Red_max[2] = 70
'initilize the 2 ultra sonic sensors in port 1 and 4 in mode 0
Sensor.SetMode(1,0)
Sensor.SetMode(4,0)
'initilize varibles
distance = 800
dir = "left"
speed = 20
'play the recorded into sound file, this canm be removed if you don't have a recorded intro sound file
Speaker.Play(100,"Sounds/Robo Dog/Intro Dog")