Post by panash on Mar 8, 2018 0:11:29 GMT
nubee here and there's probably a simple answer I'm missing.
I want to create a head tracking interface for a flight simulator. I'm going to use opencv for image acquisition and processing and use vjoy to emulate the joystick (which the flight simulator can pick up & recognise).
As part of developing a toolkit of routines I have a program which highlights the brightest & darkest points in a captured frame which works well. However when I simply import the vjoy library in it forces a reset of the shell even though there are no other active libraries or lines.
Help appreciated. Paul
I want to create a head tracking interface for a flight simulator. I'm going to use opencv for image acquisition and processing and use vjoy to emulate the joystick (which the flight simulator can pick up & recognise).
As part of developing a toolkit of routines I have a program which highlights the brightest & darkest points in a captured frame which works well. However when I simply import the vjoy library in it forces a reset of the shell even though there are no other active libraries or lines.
import numpy as np
import pyvjoy #works if I comment this line out
import cv2
cap = cv2.VideoCapture(0)
#j = pyvjoy.VJoyDevice(1)
while(True):
# Capture frame-by-frame
ret, frame = cap.read()
# Our operations on the frame come here
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
minV, maxV, minloc, maxloc = cv2.minMaxLoc(gray)
# look for darkest pixel & put a white cross
xmin = minloc[0]
ymin = minloc[1]
xmin_lft = xmin - 5
ymin_lwr = ymin - 5
xmin_right = xmin + 5
ymin_upper = ymin +5
pt1 = (xmin_lft, ymin)
pt2 = (xmin_right, ymin)
pt3 = (xmin , ymin_lwr)
pt4 = (xmin , ymin_upper)
# look for brightess pixel & put a black cross
xmax = maxloc[0]
ymax = maxloc[1]
xmax_lft = xmax - 5
ymax_lwr = ymax - 5
xmax_right = xmax + 5
ymax_upper = ymax +5
pt5 = (xmax_lft, ymax)
pt6 = (xmax_right, ymax)
pt7 = (xmax , ymax_lwr)
pt8 = (xmax , ymax_upper)
cv2.line(gray,pt1,pt2,(255,0,0),1)
cv2.line(gray,pt3,pt4,(255,0,0),1)
cv2.line(gray,pt5,pt6,(0,255,0),1)
cv2.line(gray,pt7,pt8,(0,255,0),1)
# Display the resulting frame
cv2.imshow('frame - press q to exit',gray)
# code does nothing except transfer a value over
(vjoy lines commented out until import problem resolved)
# xAxis=xmin*0x8000
# j.set_axis(HID_USAGE_X, xAxis)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()
Help appreciated. Paul