既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上C C++开发知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新
{
break;
}
}
}
void MainWindow::OnFrameCallbackFun1(GX_FRAME_CALLBACK_PARAM* frame)
{
// qDebug() << “OnFrameCallbackFun1”;
if (frame->status != 0)
{
return;
}
MainWindow pf1 = (MainWindow)(frame->pUserParam);
pf1->m_frame_first = frame;
//QImage image_circle;
uchar *pSrc = nullptr;
int id = 0; //ID号
int image_width = 0; //图像的宽
int image_height = 0; //图像的高
int64_t bayer_layout = 0; //Bayer格式
void *result_image = nullptr; //显示图像指针
QImage *show_image = nullptr;
QString device_name = “”; //相机
QString display_fps = “”; //显示帧率
image_width = (int)(pf1->m_struct_camera[id].image_width);
image_height = (int)(pf1->m_struct_camera[id].image_height);
bayer_layout = pf1->m_struct_camera[id].bayer_layout;
result_image = pf1->m_struct_camera[id].result_image;
show_image = pf1->m_struct_camera[id].show_image;
/*对原始图像进行取校准,去除畸变:求畸变参数/
pf1->frame_size[id] = cv::Size(2048, 1536);
std::string params_file = “/home/caros/baidu/adu/valetparking/modules/conf/camera_params.yml”;
load_camera_params(params_file, pf1->params[id]);
pf1->mapx[id] = cv::Mat(pf1->frame_size[id], CV_32FC1);
pf1->mapy[id] = cv::Mat(pf1->frame_size[id], CV_32FC1);
cv::Mat R = cv::Mat::eye(3, 3, CV_32F);
initUndistortRectifyMap(pf1->params[id].cameraMatrix, pf1->params[id].distCoeffs, R, pf1->params[id].cameraMatrix,
pf1->frame_size[id], CV_32FC1, pf1->mapx[id], pf1->mapy[id]);
//若支持彩色,转换为RGB图像后输出
if (pf1->m_struct_camera[id].color_filter_flag)
{
//将Raw8图像转换为RGB图像以供显示
//DxRaw8toRGB24((char*)frame->pImgBuf, result_image, image_width, image_height, RAW2RGB_NEIGHBOUR,
// DX_PIXEL_COLOR_FILTER(bayer_layout), false);
DxRaw8toRGB24((char*)frame->pImgBuf, pf1->m_circle_image[id].data, image_width, image_height,
RAW2RGB_NEIGHBOUR, DX_PIXEL_COLOR_FILTER(bayer_layout), false);
cv::remap(pf1->m_circle_image[id], pf1->m_remap_image[id], pf1->mapx[id], pf1->mapy[id], CV_INTER_LINEAR);
// input_images , output_images , the_one_map ,the_second_map,
if (calibrate_flag == true)
{
for (int i = 0; i < 13; i++)
{
cv::circle(pf1->m_remap_image[id],
cv::Point(pf1->m_remap_image[id].cols / 2, pf1->m_remap_image[id].rows * i / 12),
10, cv::Scalar(255, 255, 0), 3);
}
cv::circle(pf1->m_remap_image[id],
cv::Point(pf1->m_remap_image[id].cols / 2, pf1->m_remap_image[id].rows / 2),
10, cv::Scalar(255, 0, 0), 3);
}
if (record_flag[id] == true)
{
qDebug() << "camera1 frameindex: " << frame_index[id]++;
cv::imwrite(writer1, pf1->m_remap_image[id]);
record_flag[id] = false;
}
pSrc = (uchar*)(pf1->m_remap_image[id].data);
pf1->m_qimage[id] = QImage(pSrc, pf1->m_remap_image[id].cols, pf1->m_remap_image[id].rows,
pf1->m_remap_image[id].step, QImage::Format_RGB888);
pf1->image[id] = &(pf1->m_qimage[id]);
}
else
{
DxRaw8toRGB24((char*)frame->pImgBuf, result_image, image_width, image_height,RAW2RGB_NEIGHBOUR,
DX_PIXEL_COLOR_FILTER(NONE),false);
}
device_name.sprintf(“相机: %s”, pf1->m_baseinfo[id].szDisplayName);
display_fps.sprintf(“序列号: %s 显示帧率: %.2f FPS”, pf1->m_baseinfo[id].szSN, pf1->m_struct_camera[id].fps);
{
pf1->m_child_window[id]->ShowImage(pf1->image[id], device_name, display_fps, pf1->m_view_flag);
}
if (pf1->m_display_flag[id] == true)
{
pf1->m_child_window[id]->setWindowTitle(device_name);
pf1->m_child_window[id]->update();
pf1->m_display_flag[id] = false;
}
pf1->UpdateUI();
}
#include “stdafx.h”
#include “camera.h”
#include
#include <opencv2/opencv.hpp>
using namespace cv;
GX_DEV_HANDLE hDevice = nullptr;
static int keycode;
MERCamera::MERCamera()
{
GX_STATUS status = GX_STATUS_SUCCESS;
int64_t nValue = nullptr;
GXInitLib();
status = GXOpenDeviceByIndex(1, &hDevice);
if(status != GX_STATUS_SUCCESS)
{
std::cout<<"open error"<<std::endl;
return;
}
}
MERCamera::~MERCamera()
{
GX_STATUS emStatus = GX_STATUS_SUCCESS;
if(m_bIsSnaping)
{
EndContinuesMode();
}
emStatus = GXCloseDevice(hDevice);
if(emStatus != GX_STATUS_SUCCESS)
{
std::cout<<"close error"<<std::endl;
}
//关闭设备库
emStatus = GXCloseLib();
if(emStatus != GX_STATUS_SUCCESS)
{
std::cout<<"close lib error"<<std::endl;
}
}
void MERCamera::InitCamera()
{
GX_STATUS status = GX_STATUS_SUCCESS;
int64_t nValue = nullptr;
m_bIsSnaping = false;
status = GXGetEnum(hDevice, GX_ENUM_PIXEL_FORMAT, &m_nPixelFomat);
//获取宽度(需在停止采集状态下设置)
status = GXGetInt(hDevice, GX_INT_WIDTH, &nValue);
m_nImageWidth = (int)nValue;
//获取高度(需在停止采集状态下设置)
status = GXGetInt(hDevice, GX_INT_HEIGHT, &nValue);
m_nImageHeight = (int)nValue;
//获取图象数据大小
status = GXGetInt(hDevice, GX_INT_PAYLOAD_SIZE, &nValue);
m_nPayLoadSize = (int)nValue;
//设置采集模式。一般相机的默认采集模式为连续模式。
int64_t nAcqMode = GX_ACQ_MODE_CONTINUOUS;
status = GXSetEnum(hDevice, GX_ENUM_ACQUISITION_MODE, nAcqMode);
do
{
m_pBufferRaw8 = new BYTE[m_nImageWidth * m_nImageHeight];
if (m_pBufferRaw8 == nullptr)
{
status = GX_STATUS_ERROR;
break;
}
//为存储RGB图像数据开辟空间
m_pBufferRGB = new BYTE[m_nImageWidth * m_nImageHeight * 3];
if (m_pBufferRGB == nullptr)
{
status = GX_STATUS_ERROR;
break;
}
//为存储原始图像数据开辟空间
m_pBufferRaw = new BYTE[m_nPayLoadSize];
if (m_pBufferRaw == nullptr)
{
status = GX_STATUS_ERROR;
break;
}
} while (0);
if (status != GX_STATUS_SUCCESS)
{
if (m_pBufferRaw8 != nullptr)
{
delete[]m_pBufferRaw8;
m_pBufferRaw8 = nullptr;
}
if (m_pBufferRaw != nullptr)
{
delete[]m_pBufferRaw;
m_pBufferRaw = nullptr;
}
if (m_pBufferRGB != nullptr)
{
delete[]m_pBufferRGB;
m_pBufferRGB = nullptr;
}
}
}
void MERCamera::StartContinuesMode()
{
GX_STATUS status = GX_STATUS_SUCCESS;
InitCamera();
//注册图像处理回调函数
status = GXRegisterCaptureCallback(hDevice, NULL,OnFrameCallbackFun);
if(!m_bIsSnaping)
{
//发送开采命令
status = GXSendCommand(hDevice, GX_COMMAND_ACQUISITION_START);
m_bIsSnaping = true;
}
while(1)
{
if(keycode == ‘q’) EndContinuesMode();
}
}
void MERCamera::EndContinuesMode()
{
GX_STATUS status = GX_STATUS_SUCCESS;
if(m_bIsSnaping)
{
//发送停采命令
status = GXSendCommand(hDevice, GX_COMMAND_ACQUISITION_STOP);
//注销采集回调
status = GXUnregisterCaptureCallback(hDevice);
m_bIsSnaping = false;
}
}
//fuction:ProcessImage(BYTE* pImageBuf)
//功能:raw格式图像转换为RGB图
void MERCamera::ProcessImage(BYTE *pImageBuf)
{
//m_objDrawImg.Enter();
memcpy(m_pBufferRaw, pImageBuf, m_nPayLoadSize);
switch(m_nPixelFomat)
{
//当数据格式为12位时,位数转换为4-11
case GX_PIXEL_FORMAT_MONO12:
//将12位格式的图像转换为8位格式
DxRaw16toRaw8(m_pBufferRaw, m_pBufferRaw8, m_nImageWidth, m_nImageHeight, DX_BIT_4_11);
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
5536915881)]
[外链图片转存中…(img-gSRivIbt-1715536915881)]
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!