def thread_fun(cam_handle, pixel_format):

    block_id, image = MVGigE.read(cam_handle)

    if block_id >= 1 and block_id <= 65535:
        '''
		if g_mutex.acquire(False):
			print("[%d] locked" % cam_handle)
			h, w = image.shape
			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.imshow("CamHandle : %d"%cam_handle, rgb_image)
			elif pixel_format == MVGigE.PixelFormat_BayerRG8:
				MVGigE.cvtColor(image, rgb_image, MVGigE.COLOR_BAYER_RG2RGB)
				cv2.imshow("CamHandle : %d"%cam_handle, rgb_image)
			elif pixel_format == MVGigE.PixelFormat_BayerGB8:
				MVGigE.cvtColor(image, rgb_image, MVGigE.COLOR_BAYER_GB2RGB)
				cv2.imshow("CamHandle : %d"%cam_handle, rgb_image)
			elif pixel_format == MVGigE.PixelFormat_BayerGR8:
				MVGigE.cvtColor(image, rgb_image, MVGigE.COLOR_BAYER_GR2RGB)
				cv2.imshow("CamHandle : %d"%cam_handle, rgb_image)
			else:
				cv2.imshow("CamHandle : %d"%cam_handle, image)

			print('[%d] %d' % (cam_handle, image[100][100]))
			cv2.waitKey(1)
			print("[%d] unlocked" % cam_handle)
			g_mutex.release()
		'''
        #image_tmp = image.reshape(-1)

        #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, 9000)
    MVGigE.set(cam, MVGigE.MVCAM_PROP_TRIG_MODE, MVGigE.TriggerMode_Off)
    MVGigE.set(cam, MVGigE.MVCAM_PROP_TRIG_SOURCE,
               MVGigE.TriggerSource_Software)
Example #3
0
#coding=utf-8
import MVGigE 
import time
import datetime
import cv2
import numpy as np
CAP_TIME = 30

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)
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)
        #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])
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)
Example #7
0
#coding=utf-8
import MVGigE
import sys

dev_num = MVGigE.GetNumOfDevices()

print("find %d cameras" % dev_num)

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

    if (info['mIpAddr'][0] != info['m_IfIp'][0]) \
      or ((info['mIpAddr'][1] != info['m_IfIp'][1])) \
      or ((info['mIpAddr'][2] != info['m_IfIp'][2])):
        info['mIpAddr'][0] = info['m_IfIp'][0]
        info['mIpAddr'][1] = info['m_IfIp'][1]
        info['mIpAddr'][2] = info['m_IfIp'][2]
        info['mIpAddr'][3] = info['m_IfIp'][3] + 1

        mac = b"%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]))

        str_ip = b'%d.%d.%d.%d' % (info['mIpAddr'][0], \
         info['mIpAddr'][1], info['mIpAddr'][2], \
         info['mIpAddr'][3])

        gateway = b'%d.%d.%d.%d' % (info['mIpAddr'][0], \
Example #8
0
#coding=utf-8
import MVGigE
import time
import cv2
import datetime
import numpy as np

CAP_TIME = 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, 20000)
    #设置曝光
    MVGigE.set(cam, MVGigE.MVCAM_PROP_TRIG_MODE, MVGigE.TriggerMode_On)
    #设置打开触发
    MVGigE.set(cam, MVGigE.MVCAM_PROP_TRIG_SOURCE,
               MVGigE.TriggerSource_Software)
    #软触发
    #MVGigE.set(cam, MVGigE.MVCAM_PROP_TRIG_SOURCE, MVGigE.TriggerSource_Line1);#外触发

    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()