海康工业相机 MVS 抓图并转为Mat格式,支持彩色相机
int CMyCamera::startGrabImage(Mat &image, string &info) { unsigned int nRecvBufSize = 0; MVCC_INTVALUE stParam; memset(&stParam, 0, sizeof(MVCC_INTVALUE)); int nRet = MV_CC_GetIntValue(m_hDevHandle, "PayloadSize", &stParam); if (nRet != 0) { return -1; } nRecvBufSize = stParam.nCurValue; m_pBufForDriver = (unsigned char *)malloc(nRecvBufSize); MV_FRAME_OUT_INFO_EX stImageInfo = { 0 }; nRet = MV_CC_GetOneFrameTimeout(m_hDevHandle, m_pBufForDriver, nRecvBufSize, &stImageInfo, 1000); if (nRet != 0) { return -1; } m_nBufSizeForSaveImage = stImageInfo.nWidth * stImageInfo.nHeight * 3 + 2048; m