C2061 语法错误 标识符 Mat

weixin_40259267 2017-11-21 03:22:43

// 滤波处理1Dlg.h : 头文件
//

#pragma once


// C滤波处理1Dlg 对话框
class C滤波处理1Dlg : public CDialogEx
{
// 构造
public:
C滤波处理1Dlg(CWnd* pParent = NULL); // 标准构造函数

// 对话框数据
enum { IDD = IDD_MY1_DIALOG };

protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持


// 实现
protected:
HICON m_hIcon;

// 生成的消息映射函数
virtual BOOL OnInitDialog();
void showMatImgToWnd(CWnd*pWnd, Mat img);
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedDakai();
afx_msg void OnBnClickedLvbo();
//void showMatImgToWnd(CWnd*pWnd, Mat&img);

};


void showMatImgToWnd(CWnd*pWnd, Mat img){
if (img.empty()){
return;

}
static BITMAPINFO *bitMapinfo = NULL;
static bool First = TRUE;
if (First){
BYTE *bitBuffer = new BYTE[40 + 4 * 256];
if (bitBuffer == NULL){
return;

}
First = false;
memset(bitBuffer, 0, 40 + 4 * 256);
bitMapinfo = (BITMAPINFO*)bitBuffer;
bitMapinfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bitMapinfo->bmiHeader.biPlanes = 1;
for (int i = 0; i < 256; i++){
bitMapinfo->bmiColors[i].rgbBlue = bitMapinfo->bmiColors[i].rgbGreen = bitMapinfo->bmiColors[i].rgbRed = (BYTE)i;

}

}
bitMapinfo->bmiHeader.biHeight = -img.rows;
bitMapinfo->bmiHeader.biWidth = img.cols;
bitMapinfo->bmiHeader.biBitCount = img.channels() * 8;

CRect drect;
pWnd->GetClientRect(drect);//pWnd指向CWnd类的一个指针 
CClientDC dc(pWnd);
HDC hDC = dc.GetSafeHdc(); //HDC是Windows的一种数据类型,是设备
SetStretchBltMode(hDC, COLORONCOLOR);
StretchDIBits(hDC, 0, 0, drect.right, drect.bottom, 0, 0, img.cols, img.rows, img.data, bitMapinfo, DIB_RGB_COLORS, SRCCOPY);
}
...全文
1883 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
赵4老师 2018-03-30
  • 打赏
  • 举报
回复
引用 4 楼 weixin_40623627 的回复:
可是加了using namespace cv 又跳出来error C2871: “cv”: 具有该名称的命名空间不存在
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/contrib/contrib.hpp"

#include <opencv2/imgproc/imgproc_c.h>
幻夢之葉 2018-03-30
  • 打赏
  • 举报
回复
Mat声明的头文件你包含了吗?
真相重于对错 2018-03-30
  • 打赏
  • 举报
回复
没有include ,mat类型定义的头文件??
  • 打赏
  • 举报
回复
可是加了using namespace cv 又跳出来error C2871: “cv”: 具有该名称的命名空间不存在
  • 打赏
  • 举报
回复
谢谢各位回答,我提问之后百度了一下就改过来了 不过加了 #include <highgui.h>
weixin_40259267 2017-11-29
  • 打赏
  • 举报
回复
谢谢赵老师!
赵4老师 2017-11-21
  • 打赏
  • 举报
回复
using namespace cv;
weixin_40259267 2017-11-21
  • 打赏
  • 举报
回复
错误 1 error C2061: 语法错误: 标识符“Mat” 错误 2 error C2660: “C滤波处理1Dlg::showMatImgToWnd”: 函数不接受 2 个参数

64,654

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧