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 the necessary packages | |
from pyzbar import pyzbar | |
import cv2 | |
#--------------------------------------------------------------------------------------------------------# | |
def initCamera(camera_id, frame_width, frame_height): #Function to initialize the CV videocapture. | |
print('==> Trying to initialize the camera...') | |
cap = cv2.VideoCapture( int(camera_id) ) #Start VideoCapture with the appropriate camera ID. | |
if not cap.isOpened(): #Test if the stream is opened. |
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
Manual USB camera settings in Linux | |
https://www.kurokesu.com/main/2016/01/16/manual-usb-camera-settings-in-linux/ | |
uvcdynctrl libwebcam command line tool | |
http://www.linux-commands-examples.com/uvcdynctrl | |
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
# Pretty Print. | |
from pprint import pprint | |
playsound #is the most straightforward package to use if you simply want to play a WAV or MP3 file. It offers no functionality other than simple playback. | |
simpleaudio #lets you play WAV files and NumPy arrays, and gives you options to check whether a file is still playing. | |
winsound #allows you to play WAV files or beep your speakers, but it works only on Windows. |
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
def find_lines(frame): | |
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) | |
gray = cv2.GaussianBlur(gray,(5,5),0) | |
# ret, gray = cv2.threshold(gray,190,255,cv2.THRESH_BINARY_INV) | |
edges = cv2.Canny(gray, 30, 150, apertureSize = 3) | |
# edges = cv2.Canny(gray, 50, 200, apertureSize = 3) | |
lines = cv2.HoughLines(edges, 1, np.pi/180, 200) | |
if lines is not None: |
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
#https://stackoverflow.com/questions/166506/finding-local-ip-addresses-using-pythons-stdlib #fatal_error | |
def get_ip(self): | |
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
try: | |
# doesn't even have to be reachable | |
s.connect(('10.255.255.255', 1)) | |
IP = s.getsockname()[0] | |
except Exception: | |
IP = '127.0.0.1' | |
finally: |