Example #1
0
        public void ImageCaptureCallback(CameraHandle hCamera, uint pFrameBuffer, ref tSdkFrameHead pFrameHead, uint pContext)
        {
            //ͼ�������ԭʼ���ת��ΪRGB��ʽ��λͼ���ݣ�ͬʱ���Ӱ�ƽ�⡢���Ͷȡ�LUT��ISP�����
            MvApi.CameraImageProcess(hCamera, pFrameBuffer, (IntPtr)((int)m_ImageBuffer&(~0xf)), ref pFrameHead);
            //����ʮ���ߡ��Զ��عⴰ�ڡ���ƽ�ⴰ����Ϣ(����������Ϊ�ɼ�״̬��)��
            MvApi.CameraImageOverlay(hCamera, (IntPtr)((int)m_ImageBuffer & (~0xf)), ref pFrameHead);
            //����SDK��װ�õĽӿڣ���ʾԤ��ͼ��
            MvApi.CameraDisplayRGB24(hCamera, (IntPtr)((int)m_ImageBuffer & (~0xf)), ref pFrameHead);
            m_tFrameHead = pFrameHead;
            m_iDisplayedFrames++;

            if (pFrameHead.iWidth != m_tFrameHead.iWidth || pFrameHead.iHeight != m_tFrameHead.iHeight)
            {
                timer2.Enabled = true;
                timer2.Start();
                m_tFrameHead = pFrameHead;
            }
        }
Example #2
0
        public void CaptureThreadProc()
        {
            CameraSdkStatus eStatus;
            tSdkFrameHead FrameHead;
            uint uRawBuffer;//rawbuffer��SDK�ڲ����롣Ӧ�ò㲻Ҫ����delete֮����ͷź���

            while(m_bExitCaptureThread == false)
            {
                //500���볬ʱ,ͼ��û����ǰ���̻߳ᱻ����,�ͷ�CPU�����Ը��߳����������sleep
                eStatus = MvApi.CameraGetImageBuffer(m_hCamera, out FrameHead, out uRawBuffer, 500);

                if (eStatus == CameraSdkStatus.CAMERA_STATUS_SUCCESS)//����Ǵ���ģʽ�����п��ܳ�ʱ
                {
                    //ͼ�������ԭʼ���ת��ΪRGB��ʽ��λͼ���ݣ�ͬʱ���Ӱ�ƽ�⡢���Ͷȡ�LUT��ISP�����
                    MvApi.CameraImageProcess(m_hCamera, uRawBuffer, m_ImageBuffer, ref FrameHead);
                    //����ʮ���ߡ��Զ��عⴰ�ڡ���ƽ�ⴰ����Ϣ(����������Ϊ�ɼ�״̬��)��
                    MvApi.CameraImageOverlay(m_hCamera, m_ImageBuffer, ref FrameHead);
                    //����SDK��װ�õĽӿڣ���ʾԤ��ͼ��
                    MvApi.CameraDisplayRGB24(m_hCamera, m_ImageBuffer, ref FrameHead);
                    //�ɹ�����CameraGetImageBuffer������ͷţ��´β��ܼ�������CameraGetImageBuffer����ͼ��
                    MvApi.CameraReleaseImageBuffer(m_hCamera,uRawBuffer);

                    if (FrameHead.iWidth != m_tFrameHead.iWidth || FrameHead.iHeight != m_tFrameHead.iHeight)
                    {
                        m_bEraseBk = true;
                        m_tFrameHead = FrameHead;
                    }
                    m_iDisplayedFrames++;
                }

            }
        }
Example #3
0
 public static extern CameraSdkStatus CameraDisplayRGB24(
     CameraHandle hCamera,
     IntPtr pbyRGB24,
     ref tSdkFrameHead pFrInfo
     );
Example #4
0
        private Image convertImage(ref tSdkFrameHead tFrameHead, IntPtr pRgbBuffer)
        {
            BITMAPINFOHEADER bmi;
            BITMAPFILEHEADER bmfi;

            bmfi.bfType = ((int)'M' << 8) | ((int)'B');
            bmfi.bfOffBits = 54;
            bmfi.bfSize = (uint)(54 + tFrameHead.iWidth * tFrameHead.iHeight * 3);
            bmfi.bfReserved1 = 0;
            bmfi.bfReserved2 = 0;

            bmi.biBitCount = 24;
            bmi.biClrImportant = 0;
            bmi.biClrUsed = 0;
            bmi.biCompression = 0;
            bmi.biPlanes = 1;
            bmi.biSize = 40;
            bmi.biHeight = tFrameHead.iHeight;
            bmi.biWidth = tFrameHead.iWidth;
            bmi.biXPelsPerMeter = 0;
            bmi.biYPelsPerMeter = 0;
            bmi.biSizeImage = 0;

            MemoryStream stream = new MemoryStream();
            BinaryWriter bw = new BinaryWriter(stream);
            byte[] data = new byte[14];
            IntPtr ptr = Marshal.AllocHGlobal(54);
            Marshal.StructureToPtr((object)bmfi, ptr, false);
            Marshal.Copy(ptr, data, 0, data.Length);
            bw.Write(data);
            data = new byte[40];
            Marshal.StructureToPtr((object)bmi, ptr, false);
            Marshal.Copy(ptr, data, 0, data.Length);
            bw.Write(data);
            data = new byte[tFrameHead.iWidth * tFrameHead.iHeight * 3];
            Marshal.Copy(pRgbBuffer, data, 0, data.Length);
            bw.Write(data);
            Marshal.FreeHGlobal(ptr);
            return Image.FromStream(stream);
        }
Example #5
0
 public static extern CameraSdkStatus CameraSaveImage(
     CameraHandle hCamera,
     byte[] lpszFileName,
     IntPtr pbyImageBuffer,
     ref tSdkFrameHead pFrInfo,
     emSdkFileType byFileType,
     Byte byQuality
     );
Example #6
0
 public static extern CameraSdkStatus CameraSnapToBuffer(
     CameraHandle hCamera,
     out tSdkFrameHead pFrameInfo,
     out uint pbyBuffer,
     uint uWaitTimeMs
     );
Example #7
0
 public static extern CameraSdkStatus CameraPushFrame(
     CameraHandle hCamera,
     uint pbyImageBuffer,
     ref tSdkFrameHead[] pFrInfo
     );
Example #8
0
 public static extern CameraSdkStatus CameraImageProcessEx(
     CameraHandle hCamera,
     uint pbyIn,
     IntPtr pbyOut,
     ref tSdkFrameHead pFrInfo,
     uint uOutFormat,
     uint uReserved
     );
Example #9
0
 public static extern CameraSdkStatus CameraImageProcess(
     CameraHandle hCamera,
     uint pbyIn,
     IntPtr pbyOut,
     ref tSdkFrameHead pFrInfo
     );
Example #10
0
 public static extern CameraSdkStatus CameraImageOverlay(
     CameraHandle hCamera,
     IntPtr pRgbBuffer,
     ref tSdkFrameHead pFrInfo
     );
Example #11
0
 public static extern CameraSdkStatus CameraGetImageBuffer(
     CameraHandle hCamera,
     out tSdkFrameHead pFrameInfo,
     out uint pbyBuffer,
     uint wTimes
     );