//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public IDriver_Camera_Control   Set_Connect(CInfo_Camera_Factory CameraInfo)
        {
            if (Get_Exist(CameraInfo) == false)
            {
                return(null);
            }

            MyCamera.MV_CC_DEVICE_INFO stDevInfo;
            if (GetHikDeviceInfo(CameraInfo, out stDevInfo) == false)
            {
                return(null);
            }

            var device = new MyCamera();

            if (MyCamera.MV_OK != device.MV_CC_CreateDevice_NET(ref stDevInfo))
            {
                return(null);
            }


            if (MyCamera.MV_OK != device.MV_CC_OpenDevice_NET())
            {
                return(null);
            }

            if (CameraInfo.m_teinterface == EINTERFACE.eGIGE)
            {
                int nPacketSize = device.MV_CC_GetOptimalPacketSize_NET();
                if (nPacketSize > 0)
                {
                    if (MyCamera.MV_OK != device.MV_CC_SetIntValue_NET("GevSCPSPacketSize", (uint)nPacketSize))
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }

            var info = new MyCamera.MV_IMAGE_BASIC_INFO();

            if (MyCamera.MV_OK != device.MV_CC_GetImageInfo_NET(ref info))
            {
                return(null);
            }

            var camera = new Control_HikCamera(device, info);

            if (MyCamera.MV_OK != device.MV_CC_RegisterImageCallBackEx_NET(Control_HikCamera.ImageCallback, GCHandle.ToIntPtr(camera.Handle)))
            {
                return(null);
            }

            return(camera);
        }
Example #2
0
        public ICamera Connect(CameraInfo cameraInfo)
        {
            if (IsExist(cameraInfo) == false)
            {
                return(null);
            }

            MyCamera.MV_CC_DEVICE_INFO stDevInfo;
            if (GetHikDeviceInfo(cameraInfo, out stDevInfo) == false)
            {
                return(null);
            }

            var device = new MyCamera();

            if (MyCamera.MV_OK != device.MV_CC_CreateDevice_NET(ref stDevInfo))
            {
                return(null);
            }

            if (MyCamera.MV_OK != device.MV_CC_OpenDevice_NET())
            {
                return(null);
            }

            if (cameraInfo.CameraType == ECameraType.GIGE)
            {
                int nPacketSize = device.MV_CC_GetOptimalPacketSize_NET();
                if (nPacketSize > 0)
                {
                    if (MyCamera.MV_OK != device.MV_CC_SetIntValue_NET("GevSCPSPacketSize", (uint)nPacketSize))
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }

            var info = new MyCamera.MV_IMAGE_BASIC_INFO();

            if (MyCamera.MV_OK != device.MV_CC_GetImageInfo_NET(ref info))
            {
                return(null);
            }

            var camera = new HikCamera(device, info);

            if (MyCamera.MV_OK != device.MV_CC_RegisterImageCallBackEx_NET(HikCamera.ImageCallback, GCHandle.ToIntPtr(camera.Handle)))
            {
                return(null);
            }

            return(camera);
        }
Example #3
0
        public HikCamera(MyCamera device, MyCamera.MV_IMAGE_BASIC_INFO info)
        {
            _imageCallback = new MyCamera.cbOutputExdelegate(ImageCallbackFunc);
            _handle        = GCHandle.Alloc(this);

            _device = device;
            _info   = info;

            _count     = 0;
            _grabCount = -1;
        }