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; } }
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++; } } }
public static extern CameraSdkStatus CameraDisplayRGB24( CameraHandle hCamera, IntPtr pbyRGB24, ref tSdkFrameHead pFrInfo );
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); }
public static extern CameraSdkStatus CameraSaveImage( CameraHandle hCamera, byte[] lpszFileName, IntPtr pbyImageBuffer, ref tSdkFrameHead pFrInfo, emSdkFileType byFileType, Byte byQuality );
public static extern CameraSdkStatus CameraSnapToBuffer( CameraHandle hCamera, out tSdkFrameHead pFrameInfo, out uint pbyBuffer, uint uWaitTimeMs );
public static extern CameraSdkStatus CameraPushFrame( CameraHandle hCamera, uint pbyImageBuffer, ref tSdkFrameHead[] pFrInfo );
public static extern CameraSdkStatus CameraImageProcessEx( CameraHandle hCamera, uint pbyIn, IntPtr pbyOut, ref tSdkFrameHead pFrInfo, uint uOutFormat, uint uReserved );
public static extern CameraSdkStatus CameraImageProcess( CameraHandle hCamera, uint pbyIn, IntPtr pbyOut, ref tSdkFrameHead pFrInfo );
public static extern CameraSdkStatus CameraImageOverlay( CameraHandle hCamera, IntPtr pRgbBuffer, ref tSdkFrameHead pFrInfo );
public static extern CameraSdkStatus CameraGetImageBuffer( CameraHandle hCamera, out tSdkFrameHead pFrameInfo, out uint pbyBuffer, uint wTimes );