import MVGigE
import numpy as np
import cv2


#执行例子后会显示第一个相机采集到的图,按任意键显示下一个相机的图
def cam_set_para(cam):
    #MVGigE.set(cam, MVGigE.MVCAM_PROP_PACKET_DELAY, 5000);
    #MVGigE.set(cam, MVGigE.MVCAM_PROP_PACKET_SIZE, 8996);
    MVGigE.set(cam, MVGigE.MVCAM_PROP_EXPOSURE, 9000)
    MVGigE.set(cam, MVGigE.MVCAM_PROP_TRIG_MODE, MVGigE.TriggerMode_Off)
    MVGigE.set(cam, MVGigE.MVCAM_PROP_TRIG_SOURCE,
               MVGigE.TriggerSource_Software)


iCams = MVGigE.GetNumOfCameras()
print("CamMum = %d" % iCams)
CAM_NUMBER = iCams
cam = np.zeros(CAM_NUMBER)

for index in range(CAM_NUMBER):
    open_state, cam[index] = MVGigE.open(index)

    if open_state == True:
        pixel_format = MVGigE.get(cam[index], MVGigE.MVCAM_PROP_PIXELFORMAT)
        print("%d  %d " % (index, cam[index]))
        cam_set_para(cam[index])

        w = MVGigE.get(cam[index], MVGigE.MVCAM_PROP_WIDTH)
        h = MVGigE.get(cam[index], MVGigE.MVCAM_PROP_HEIGHT)
Esempio n. 2
0
        #print('[%d] %d' % (cam_handle, image[100][100]))
        return True, block_id, 0, 0  #np.mean(image_tmp), np.var(image_tmp)
    return False, 0, 0, 0


def cam_set_para(cam):
    #MVGigE.set(cam, MVGigE.MVCAM_PROP_PACKET_DELAY, 5000);
    MVGigE.set(cam, MVGigE.MVCAM_PROP_PACKET_SIZE, 8996)
    MVGigE.set(cam, MVGigE.MVCAM_PROP_EXPOSURE, 2000)
    MVGigE.set(cam, MVGigE.MVCAM_PROP_TRIG_MODE, MVGigE.TriggerMode_Off)


if __name__ == "__main__":
    capture_time = 10  #
    #print('times: ', sys.argv[1])
    cam_numbers = MVGigE.GetNumOfCameras()
    print("CamMum = %d" % cam_numbers)

    threads = []
    cam_handles = []
    cam_handles_tmp = []
    threads_tmp = []

    for index in range(cam_numbers):
        thread = -1
        open_state, cam_handle = MVGigE.open(index)
        if open_state:
            cam_set_para(cam_handle)
            pixel_format = MVGigE.get(cam_handle,
                                      MVGigE.MVCAM_PROP_PIXELFORMAT)
            thread = Capture_Thread(thread_fun, [cam_handle, pixel_format])
Esempio n. 3
0
        if(MVGigE.ForceIp(mac, \
         str_ip, \
         b'255.255.255.0', b'0.0.0.0') != 0):
            print(i, ' forceip error')

    #ip = b"192.168.11.60"
    #gateway = b"192.168.11.1"
    #subnet_mask = b"255.255.255.0"
    #mac = bytes([info["mEthernetAddr"][0], \
    #		info["mEthernetAddr"][1], info["mEthernetAddr"][2],    \
    #		info["mEthernetAddr"][3], info["mEthernetAddr"][4],    \
    #		info["mEthernetAddr"][5]])
    #mac = bytes("%c%c%c%c%c%c" % (int(info["mEthernetAddr"][0]), \
    ##		int(info["mEthernetAddr"][1]), int(info["mEthernetAddr"][2]),    \
    #		int(info["mEthernetAddr"][3]), int(info["mEthernetAddr"][4]),    \
    #		int(info["mEthernetAddr"][5])))
    #print(mac)

print("==================================")

dev_num = MVGigE.GetNumOfCameras()

print("find %d cameras" % dev_num)

for i in range(dev_num):
    info = MVGigE.GetCameraInfo(i)
    print("[%d]IP : %d.%d.%d.%d" % (i, info["mIpAddr"][0],   \
     info["mIpAddr"][1], info["mIpAddr"][2],  \
     info["mIpAddr"][3]))