Esempio n. 1
0
            elif cam_handle == MVGigE.MVST_INVALID_PARAMETER:
                print("incalied parameter")
            elif cam_handle == MVGigE.MVST_ACCESS_DENIED:
                print("access denied")
            elif cam_handle == MVGigE.MVST_INVALID_ID:
                print("invalid id")
            else:
                print("other error [%d]" % cam_handle)

    for index in range(len(cam_handles_tmp)):
        #open_state, cam_handle = MVGigE.open(index)
        #if open_state == True:
        cam_handle = cam_handles_tmp[index]
        thread = threads_tmp[index]

        if (MVGigE.start(cam_handle)):
            #cv2.namedWindow("CamHandle : %d"%cam_handle)

            threads.append(thread)

            cam_handles.append(cam_handle)
        else:
            MVGigE.close(cam_handle)
            if thread != -1:
                thread.stop()

    start_time = datetime.datetime.now()

    while 1:
        end_time = datetime.datetime.now()
        if (end_time - start_time).seconds > capture_time:
Esempio n. 2
0
open_state, cam = MVGigE.open(0)

if open_state == True:
	#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);
	
	w = MVGigE.get(cam, MVGigE.MVCAM_PROP_WIDTH)
	h = MVGigE.get(cam, MVGigE.MVCAM_PROP_HEIGHT)
	pixel_format = MVGigE.get(cam, MVGigE.MVCAM_PROP_PIXELFORMAT)
	rgb_image = np.zeros((h, w, 3), np.uint8)
	print('w %d; h %d;' % (w, h))

	if(MVGigE.start(cam)):
		frames = 0
		start_time = datetime.datetime.now()
	
		while(1):
			MVGigE.TriggerSoftware(cam)
			
			while 1:
				read_state, image = MVGigE.read(cam)
				if read_state == True:
					if pixel_format == MVGigE.PixelFormat_BayerBG8:
						MVGigE.cvtColor(image, rgb_image, MVGigE.COLOR_BAYER_BG2RGB)
						cv2.imshow('img', rgb_image)
					elif pixel_format == MVGigE.PixelFormat_BayerRG8:
						MVGigE.cvtColor(image, rgb_image, MVGigE.COLOR_BAYER_RG2RGB)
						cv2.imshow('img', rgb_image)
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)

        print('[%d] w %d; h %d;' % (index, w, h))
        rgb_image = np.zeros((h, w, 3), np.uint8)

        if (MVGigE.start(cam[index])):
            while (1):
                read_state, image = MVGigE.read(cam[index])
                Title = ["CamID : %d" % index]
                if read_state == True:
                    rgb_image = np.zeros((h, w, 3), np.uint8)
                    if pixel_format == MVGigE.PixelFormat_BayerBG8:
                        MVGigE.cvtColor(image, rgb_image,
                                        MVGigE.COLOR_BAYER_BG2RGB)
                        cv2.imwrite("img_%d.jpg" % index, rgb_image)
                        cv2.imshow("CamID : %d" % index, rgb_image)
                    elif pixel_format == MVGigE.PixelFormat_BayerRG8:
                        MVGigE.cvtColor(image, rgb_image,
                                        MVGigE.COLOR_BAYER_RG2RGB)
                        cv2.imwrite("img_%d.jpg" % index, rgb_image)
                        cv2.imshow("CamID : %d" % index, rgb_image)