Skip to content

Instantly share code, notes, and snippets.

'First 55 lines of code are to open and read from a file that was written by the cube recognition program
'The recongition program was written in python running on a raspberry pi
'It was orginally intended that it would run as a webserver using flask and this Small Basic program would use the Network.GetWebPageContents to get the data
'the file has 12 lines, 6 sets of 2 pairs of lines. First line is which face it is and the second line is a string of 9 char of the colors of that face
'We have 6 arrays that are 2 dimentional 3 x 3 (row,colum) to store the colors
For line = 1 To 6
dataface = File.ReadLine("C:\Data\Robitics\MacTwist.txt",line*2-1)
datatile = File.ReadLine("C:\Data\Robitics\MacTwist.txt",line*2)
@flyboy74
flyboy74 / cuberead5.pu
Created February 18, 2017 09:42
Rubik's Cube detection written in Python
from picamera.array import PiYUVArray
from picamera import PiCamera
import time
import cv2
import numpy as np
import colorsys
#set Pi Camera settings
camera = PiCamera()
camera.resolution = (640, 480)
'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")
@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
@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 / 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_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_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_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_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)