项目中需要用到多个相机采集图像。采用的是大恒VC SDK,并将图像转换成opencv的Mat。这里接了6个相机。
配置opencv3.4和大恒VC SDK



源代码
#include <iostream>
#include <opencv2/opencv.hpp>
//using namespace cv;
using namespace std;
#include"GxIAPI.h"
#include"DxImageProc.h"
//图像回调处理函数
cv::Mat img_1, img_2, img_3, img_4, img_5, img_6;
static void GX_STDC OnFrameCallbackFun_1(GX_FRAME_CALLBACK_PARAM* pFrame)
{
if (pFrame->status == GX_FRAME_STATUS_SUCCESS)
{
//对图像进行某些操作
cout << "Yes_Camera_1" << endl;
img_1.create(pFrame->nHeight, pFrame->nWidth, CV_8UC3);
//cout << "CCC" << pFrame->nImgSize << endl;
//cout << "xx" << pFrame->pImgBuf << endl;
char *pRGB24Buffer = new char[(pFrame->nHeight) * (pFrame->nWidth) * 3];
DxRaw8toRGB24((void*)pFrame->pImgBuf, pRGB24Buffer, pFrame->nWidth, pFrame->nHeight, RAW2RGB_NEIGHBOUR, BAYERRG, false);
//cout << << endl;
memcpy(img_1.data, pRGB24Buffer, (pFrame->nHeight) * (pFrame->nWidth) * 3);
cv::imshow("sss_1", img_1);
cv::waitKey(1);
delete[]pRGB24Buffer;
}
return;
}
static void GX_STDC OnFrameCallbackFun_2(GX_FRAME_CALLBACK_PARAM* pFrame)
{
if (pFrame->status == GX_FRAME_STATUS_SUCCESS)
{
//对图像进行某些操作
cout << "Yes_Camera_2" << endl;
img_2.create(pFrame->nHeight, pFrame->nWidth, CV_8UC3);
//cout << "CCC" << pFrame->nImgSize << endl;
//cout << "xx" << pFrame->pImgBuf << endl;
char *pRGB24Buffer = new char[(pFrame->nHeight) * (pFrame->nWidth) * 3];
DxRaw8toRGB24((void