Hi,
im new on this forum. I just started (3 weeks ago) with jetbot.
is it possible to see the image from camera (PC), while driving with gamepad?
In bottom code i only want to recieve data from gamepad but im not succesfull, program crashes on “code = outGamepad.get()”
My code for gamepad controlling the jetbot is in separate program.
I tryed using multiprocessing, also with threading no success.
Is it maybe any other way to get data, and also maybe how could i run the proces for gamepad only if some but is pressed? Probably the problem is in this infinite loop for gamepad.
from multiprocessing import Process, Queue
import cv2
from inputs import get_gamepad
dispW=640
dispH=480
flip=0
# Gstreamer code for improvded Raspberry Pi Camera Quality
camSet='nvarguscamerasrc wbmode=1 tnr-mode=2 tnr-strength=1 ee-mode=2 ee-strength=1 ! video/x-raw(memory:NVMM), width=3264, height=2464, format=NV12, framerate=21/1 ! nvvidconv flip-method='+str(flip)+' ! video/x-raw, width='+str(dispW)+', height='+str(dispH)+', format=BGRx ! videoconvert ! video/x-raw, format=BGR ! videobalance contrast=2.0 brightness=-.1 saturation=1.5 ! appsink'
def get_frame(cap):
cap.grab()
retval, frame = cap.read()
return frame
def gamepad(outGamepad):
#while True:
events = get_gamepad()
for event in events:
print(event.ev_type, event.code, event.state)
data=event.code
outGamepad.put(data)
outGamepad = Queue(1)
cap = cv2.VideoCapture(camSet)
p1 = Process(target=gamepad, args=(outGamepad,))
p1.start()
while cap.isOpened():
frame = get_frame(cap)
cv2.imshow('Cam',frame)
cv2.moveWindow('Cam',0,0)
if cv2.waitKey(1)==ord('q'):
break
code = outGamepad.get()
p1.terminate()
cap.release()
cv2.destroyAllWindows()
Thank you