from MVCam_py import MVCam import cv2 import numpy as np import sys import time if __name__ == "__main__": MVCam1 = MVCam() MVCam1.EnumerateDevice() cv2.namedWindow('img') hCam = MVCam1.Init("cam44") MVCam1.SetImageResolution(hCam, 1280, 960) MVCam1.SetExposureTime(hCam, 10000) print 'play', MVCam1.Play(hCam) print 'SetTriggerMode', MVCam1.SetTriggerMode(hCam, 1) # print 'CameraSetTriggerCount', MVCam1.SetTriggerCount(hCam, 1) time.sleep(2) t = time.time() while True: # print 'SetTriggerMode', MVCam1.SetTriggerMode(hCam, 1) # time.sleep(0.01) print 'SoftTrigger', MVCam1.SoftTrigger(hCam) # MVCam1.Play(hCam) img0 = MVCam1.getImage(hCam, 1000) # MVCam1.Stop(hCam) print time.time() - t
# def NoiseFilter(pos): # global cam_list # global hCam # New = cv2.getTrackbarPos('NoiseFilter', cam_name) # # print pos # New = True if New else False # print 'NoiseFilter:', MVCam1.SetNoiseFilter(hCam, New) #FOV max value is (1280-640, 960-480) def createTrackbar_FOV(Width, Height): cv2.createTrackbar('VOffsetFOV', cam_name, 0, 1280-Width, FOV) cv2.createTrackbar('HOffsetFOV', cam_name, 0, 960-Height, FOV) if __name__ == '__main__': MVCam1 = MVCam() if not MVCam1.EnumerateDevice(): print 'Cannot find any cameras!' exit(-1) resolution = (1280, 1024) cam_list = MVCam1.Getname() cam_list = cam_list.split(',') print '-------------------------------------------------' print 'There are all cameras we Found!' for i, name in enumerate(cam_list): print "%d "%i + name print 'Please input 0~%d to open camera:' % (len(cam_list)-1), index = int(raw_input()) if index not in range(len(cam_list)): print "inpur error!!!" exit(-1)
while True: time.sleep(1) # t0 = time.time() print 'SoftTrigger', MVCam1.SoftTrigger(hCam) print 'before read: ', time.time() - t0 img0 = MVCam1.getImage(hCam, 1000) print 'end read: ', time.time() - t0 print 'end read: ', time.time() - t0 print 'end read: ', time.time() - t0 print 'end read: ', time.time() - t0 if __name__ == "__main__": t0 = time.time() MVCam1 = MVCam() MVCam1.EnumerateDevice() hCam = MVCam1.Init("Cam3") MVCam1.SetImageResolution(hCam, 1280, 960) MVCam1.SetExposureTime(hCam, 10000) print 'SetTriggerMode', MVCam1.SetTriggerMode(hCam, 1) print 'play', MVCam1.Play(hCam) th = threading.Thread(target=getimg, args=(MVCam1, hCam)) th.daemon = True print 'before st' th.start() print 'st done' st = time.time()
from MVCam_py import MVCam import cv2 import numpy as np import time if __name__ == '__main__': num = 0 while True: print num hCam = 0 num += 1 MV = MVCam() # print 'aaaaa' MV.EnumerateDevice() print MV.getMVNum() hCam = MV.Init('Cam5') hCam1 = MV.Init('cam2') print 'Init', hCam print 'Init', hCam1 # print 'Stop', MV.Stop(hCam) print 'UnInit', MV.UnInit(hCam) print 'UnInit1', MV.UnInit(hCam1) time.sleep(1) del MV
global cam_list Newred = cv2.getTrackbarPos('red', cam_list[0]) Newgreen = cv2.getTrackbarPos('green', cam_list[0]) Newblue = cv2.getTrackbarPos('blue', cam_list[0]) Newsaturation = cv2.getTrackbarPos('saturation', cam_list[0]) print 'colorTempset:', MVCam1.SetColorTemp(cam_list[0],Newred,Newgreen,Newblue,Newsaturation) def gammacontrast(pos): global cam_list Newgamma = cv2.getTrackbarPos('gamma', cam_list[0]) Newcontrast = cv2.getTrackbarPos('contrast', cam_list[0]) # print pos print 'gammacontrast:', MVCam1.SetContrast(cam_list[0], Newgamma,Newcontrast) FastPhotoModel = '' MVCam1 = MVCam(FastPhotoModel,3) # cv2.namedWindow("MVCam1", cv2.WINDOW_NORMAL) cam_list = ['Cam5','Cam7'] i = 0 cv2.namedWindow(cam_list[0], cv2.WINDOW_NORMAL) MVCam1.releaseImageBuffer(cam_list[0]) MVCam1.releaseImageBuffer(cam_list[1]) flag = MVCam1.openCam(cam_list[0]) flag = MVCam1.openCam(cam_list[1]) print 'start' cv2.createTrackbar('expose', cam_list[0], 30000, 100000, expose) cv2.createTrackbar('red', cam_list[0], 100, 399, colorTemp) cv2.createTrackbar('green', cam_list[0], 100, 399, colorTemp) cv2.createTrackbar('blue', cam_list[0], 100, 399, colorTemp) cv2.createTrackbar('saturation', cam_list[0], 100, 200, colorTemp)
from MVCam_py import MVCam import cv2 import time import numpy as np if __name__ == "__main__": # MVCamE = {} # for i in (0,1): # print 'i',i # MVCamE[i] = MVCam() # print 'EnumerateDevice', MVCamE[i].EnumerateDevice() # MVCam1 = MVCamE[0] # MVCam0 = MVCamE[1] MVCam1 = MVCam() print 'EnumerateDevice', MVCam1.EnumerateDevice() print 'Cam Init' Cam_list = ['Cam5','Cam1'] cv2.namedWindow("MVCam0") # print 'open:',MVCam1.isOpen(Cam_list[0]) # print MVCam1.getchar() hCam = MVCam1.Init(Cam_list[0]) # hCam0 = MVCam0.Init(Cam_list[1]) # print 'ConnectTest', MVCam1.ConnectTest(hCam) print 'hCam',hCam # print 'hCam0',hCam0 print 'getMVNum',MVCam1.getMVNum() print 'SetAeState', MVCam1.SetAeState(hCam,False) MVCam1.SetExposureTime(hCam,60000) print 'SetAnalogGain', MVCam1.SetAnalogGain(hCam,1)