Beispiel #1
0
        glyph.compute_glyph(source)
        if jsg.compare_glyphs(glyph.glyph_matrix,target_list):
            cv2.drawContours(source,[glyph.approx_poly],0,(0,255,0),1)
            cv2.circle(source,(glyph.cx,glyph.cy),2,(255,0,255),-1)
            #cv2.putText(source,str(glyph.nr), (glyph.cx,glyph.cy), cv2.FONT_HERSHEY_PLAIN, 2, (255,255,0), 2)
            delta_array = jsg.delta_to_center(source, glyph)
            #print delta_array
            for item in delta_array:
                if abs(delta_array[0]) > 0.1 and (cv2.getTickCount()-ptz_last_command_tick > ptz_gracetime_ticks):
                    print "pan",item
                    ptz.relative_pan(P_GAIN_PAN*delta_array[0])
                    command_this_frame = 1
                    
                if abs(delta_array[1]) > 0.5 and (cv2.getTickCount()-ptz_last_command_tick > ptz_gracetime_ticks):
                    print "tilt",-0.01*delta_array[0]
                    ptz.tilt(P_GAIN_TILT*delta_array[1])
                    command_this_frame = 1
                    
                if command_this_frame:
                    ptz_last_command_tick = cv2.getTickCount()
                    
                command_this_frame = 0
            #cv2.imshow('Roi',glyph.img_roi)
            #cv2.imshow('Otsu',glyph.img_roi_otsu)
           
    cv2.namedWindow('Source')
    cv2.setMouseCallback('Source',interactive_drawing)

    for item in cross:
        cv2.putText(source,'+', (item[0]-(baseline[0][0]/2),item[1]+(baseline[0][1]/2)), cv2.FONT_HERSHEY_PLAIN, 2, (255,0,255), 2)
    
Beispiel #2
0
CAM_AUTH = requests.auth.HTTPDigestAuth("root", "mhwirth")

GAIN = 10

# payload = { 'rpan':'10' }
# response = requests.post(CAMERA_URL, data=payload, auth=CAM_AUTH)

window = np.zeros((1, 1, 3), np.uint8)

while True:
    cv2.namedWindow("Joystick")
    cv2.imshow("Joystick", window)

    key = cv2.waitKey(1)
    if key == 27:
        exit(0)
    elif key == 115:
        print "Up"
        ptz.tilt(-GAIN)
    elif key == 119:
        print "Down"
        ptz.tilt(GAIN)
    elif key == 97:
        print "Right"
        ptz.relative_pan(-GAIN)
    elif key == 100:
        print "Left"
        ptz.relative_pan(GAIN)
    else:
        print key
Beispiel #3
0
CAM_AUTH = requests.auth.HTTPDigestAuth('root', 'mhwirth')

GAIN = 10

#payload = { 'rpan':'10' }
#response = requests.post(CAMERA_URL, data=payload, auth=CAM_AUTH)

window = np.zeros((1,1,3), np.uint8)

while True:
    cv2.namedWindow('Joystick')
    cv2.imshow('Joystick',window)

    key = cv2.waitKey(1)
    if key == 27:
        exit(0)
    elif key == 115:
        print "Up"
        ptz.tilt(-GAIN)
    elif key == 119:
        print "Down"
        ptz.tilt(GAIN)
    elif key == 97:
        print "Right"
        ptz.relative_pan(-GAIN)
    elif key == 100:
        print "Left"
        ptz.relative_pan(GAIN)
    else:
        print key