Raspbian error libraries with GoPiGo
I am working on GoPiGo and I am trying to get this robot to move when the camera detects a circle.
Basically the problem is that when I try to use the gopigo library to use functions like fwd (), stop (), etc. if I DO NOT use sudo on the command line and just type "python CircleDetector_MOVEMENT.py" it detects gopigo library but doesn't detect picamera.array:
Traceback (most recent call last): File "CircleDetector_MOVEMENT.py", line 2, in <module> from picamera.array import PiRGBArray ImportError: No module named picamera.array
which I am importing from PIRGBarray. And when I use sudo python myprogram.py it does NOT detect the gopigo library and the error is as follows:
Traceback (most recent call last): File "CircleDetector_MOVEMENT.py", line 8, in <module> from gopigo import * #Has the basic functions for controlling the GoPiGo Robot ImportError: No module named gopigo
I'm guessing it might be permission related, but I have no idea how to solve it.
So, if you know what might be here, I will be grateful. On their forum I was told that this is an I2C problem, but I am still a noob in all this, and I do not know how to solve it.
Any help is appreciated.
PS Here you are my code if it helps:
#import everything i need to get working all modules. from picamera.array import PiRGBArray from picamera import PiCamera import time import cv2 import os import numpy as np from gopigo import * #Has the basic functions for controlling the GoPiGo Robot import sys #Used for closing the running program os.system('sudo modprobe bcm2835-v4l2') h=200 w=300 camera = PiCamera() camera.resolution = (w, h) camera.framerate = 5 rawCapture = PiRGBArray(camera, size=(w, h)) time.sleep(0.1) for frame in camera.capture_continuous(rawCapture, format="bgr", use_video_port=True): imagen_RGB = frame.array copia_RGB = imagen_RGB.copy() gris = cv2.cvtColor(imagen_RGB, cv2.COLOR_BGR2GRAY) gris = cv2.medianBlur(gris,9) img_circulos = None img_circulos = cv2.HoughCircles(gris, cv2.cv.CV_HOUGH_GRADIENT, 1, 20, param1=50, param2=50, minRadius=0, maxRadius=0) if img_circulos is not None: v = 1 img_circulos = np.round(img_circulos[0, :]).astype("int") for (x, y, r) in img_circulos: cv2.circle(copia_RGB, (x, y), r, (0, 255, 0), 3) cv2.rectangle(copia_RGB, (x - 5, y - 5),(x + 5, y + 5), (0, 128, 255, -1)) if v == 1 fwd() cv2.imshow("Imagen Combinada", copia_RGB) key = cv2.waitKey(1) & 0xFF rawCapture.truncate(0) if key == ord("q"): break
source to share