【DIP Learining MFC &OpenCV】 Experience by 20171026
This day saw the progress I achieved in creating a fusion of MFC frame and OpenCV code as well as some settled problems. But it is quite late now cause the time for me to prepare the small thesis of the Micro-computer course is not enough, if I spent further time on writing this today. So I'm gonna display those settled problems here and finish this essay the other day, in the future but soon.
[1]Open files(especially images) in dialog-based MFC programme by selecting files in a new dialog, which is just like what we use to see in Windows system;
[2]Switch the CString vars to char* or string vars;
[3]Show the image in picture control without stretching it even with scaling considered;
[4]Remove the former image while displaying a new one;
[5]How to deal with the error which appears when we try to open a image without choosing anything;
[6]Cope with the error that .png images can not be opened.
unfinished...2017-10-26 21:26:25
===========================================
updated
===========================================
Firstly, we should choose a starting button in a dialog or in a menu. In this programme, menu is chosen. If you have no idea how to create a new dialog by clicking the menu, turn to this article:#MFC Programming# Using Dialog To Set A Correlate Menu
Since we have got a dialog and a correlate menu, what we need to do create a system dialog which can implement file-reading and file-saving[1].
To start with, we should add a new class of the dialog but the dialog Delimage in this project has had a class when the dialog-based project is created. Therefore, we just need to add a event handler of the submenu Open:
Now we open the Event Handler Wizard:
Any class in the class view is ok but considering convenience and visibility, we choose CCV_OpenImageDlg followed by editing the code:
(Actually followed by Add and Edit because I have already added one)
Then a message response function OnImageopen() is created. It is time that we started writing the code:
void CCV_OpenImageDlg::OnImageopen()
{
Invalidate(); //Update the dialog including the picture control
CFileDialog dlg(TRUE, NULL, NULL, OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_READONLY,
TEXT("支持的图像文件 (*.jpg;*.png;*.gif;*.bmp;...)|*.jpg;*.png;*.gif;*.bmp|专用Tiff图像文件(*.tiff;*.tif)|*.tiff;*.tif|所有文件(*.*)|*.*||"), NULL);
dlg.m_ofn.nFilterIndex = ;
dlg.m_ofn.hwndOwner = m_hWnd;
dlg.m_ofn.lStructSize = sizeof(OPENFILENAME);
dlg.m_ofn.lpstrTitle = TEXT("打开图像文件...\0");
dlg.m_ofn.nMaxFile = MAX_PATH;
if (dlg.DoModal() == IDOK)
{
m_path = dlg.GetPathName();
UpdateData(FALSE);
}
else
return;
//string s_path(m_path.GetBuffer()); //then there should be #include <string.h>
char *s_path;
s_path = m_path.GetBuffer(m_path.GetLength()); //switch CString to Char *
m_StaticPath.SetWindowTextA(m_path); //write the image path to static text control
Mat Mat_image = imread(s_path, );
IplImage image = Mat_image;
DrawPicToHDC(&image, ID_SHOWLEFT);
}
Display of result:
unfinished...2017-10-28 11:39:59
【DIP Learining MFC &OpenCV】 Experience by 20171026的更多相关文章
- 【从零学习openCV】IOS7下的人脸检測
前言: 人脸检測与识别一直是计算机视觉领域一大热门研究方向,并且也从安全监控等工业级的应用扩展到了手机移动端的app,总之随着人脸识别技术获得突破,其应用前景和市场价值都是不可估量的,眼下在学习ope ...
- 【从零学习openCV】IOS7根据人脸检测
前言: 人脸检測与识别一直是计算机视觉领域一大热门研究方向,并且也从安全监控等工业级的应用扩展到了手机移动端的app.总之随着人脸识别技术获得突破,其应用前景和市场价值都是不可估量的,眼下在学习ope ...
- 【从零学习openCV】IOS7人脸识别实战
前言 接着上篇<IOS7下的人脸检測>,我们顺藤摸瓜的学习怎样在IOS7下用openCV的进行人脸识别,实际上非常easy,因为人脸检測部分已经完毕,剩下的无非调用openCV的方法对採集 ...
- 【温故知新C/C++/opencv】取址符&||cv::groupRectangles||引用与值传递
cv::groupRectangles void groupRectangles(vector<Rect>& rectList, int groupThreshold, doubl ...
- 【从零学习openCV】opecv操作像素
1. 存取像素值 在opencv中能够直接对cv::Mat类型的图像调用at函数读取或赋值某个像素,我们用个简单的案例来说明: //在一张图像上增加椒盐噪声,image为输入图像.n为噪点个数 voi ...
- 【从零学习openCV】IOS7下的openCV开发起步(Xcode5.1.1&openCV2.49)
前言: 开发IOS7已经有一月的时间了.近期在准备推研的事,有点想往CV方向发展.于是開始自学openCV. 关注CSDN已经非常久了.也从非常多博主那学到了非常多知识,于是我也从这周开启自己的blo ...
- 【OpenCV】边缘检测:Sobel、拉普拉斯算子
推荐博文,博客.写得很好,给个赞. Reference Link : http://blog.csdn.net/xiaowei_cqu/article/details/7829481 一阶导数法:梯度 ...
- 【C# -- OpenCV】Emgu CV 第一个实例
原文 [C# -- OpenCV]Emgu CV 第一个实例 Emgu CV下载地址 http://sourceforge.net/projects/emgucv/files/ 找最新的下就行了,傻瓜 ...
- 【图像算法OpenCV】几何不变矩--Hu矩
原文地址 http://blog.csdn.NET/daijucug/article/details/7535370 [图像算法OpenCV]几何不变矩--Hu矩 一 原理 几何矩是由Hu(Visu ...
随机推荐
- ios3--UIView的常见方法
// // ViewController.m // 07-UIView的常见方法 // #import "ViewController.h" @interface ViewCont ...
- 【转】Android Fragment中使用SurfaceView切换时闪一下黑屏的解决办法
重构了下之前自己的一个新闻客户端,全部使用了Fragment来进行页面切换,只有一个入口Activity作为程序的启动Activity,其中有一个界面需要调用摄像头识别二维码, 于是就会用到Surfa ...
- Android showDialog时报错requestFeature() must be called before adding content
View view = View.inflate(this, R.layout.layout_dialog, null); AlertDialog alertDialog = new AlertDia ...
- android kl 文件的作用【转】
本文转载自:http://blog.csdn.net/u013308744/article/details/49274069 首先看touchscreen的kl文件 # Copyright (c) 2 ...
- Android 体系结构介绍
转自:http://blog.sina.com.cn/s/blog_4bc996c40100fawo.html 第一.操作系统层(OS)第二.各种库(Libraries)和Android 运行环境(R ...
- C# MySql Select
MySqlCommand objCmd = new MySqlCommand("select * from `main_db`.`t_realdailyinfo` ", objCo ...
- Linux进程状态解析
引言 Linux是一个多用户,多任务的系统,可以同时运行多个用户的多个程序,就必然会产生很多的进程,而每个进程会有不同的状态. 在下文将对进程的R.S.D.T.Z.X 六种状态做个说明. PROCE ...
- Akka源码分析-Remote-Actor创建
在之前的博客中,我们分析过local模式下Actor的创建过程,最终还是调用了provider的actorOf的函数创建了Actor,在remote模式下provider就是RemoteActorRe ...
- 《Akka应用模式:分布式应用程序设计实践指南》读书笔记9
性能 这也是一个比较大的问题,因为性能不一定是Akka本身的问题,还可能是你代码写的有问题. 优化的第一步就是找出性能的瓶颈,隔离出应用程序里面比较耗时的部分,然后尝试对其优化,减少需要耗费的时间成本 ...
- IOC框架---什么是IOC
1 IoC理论的背景 我们都知道,在采用面向对象方法设计的软件系统中,它的底层实现都是由N个对象组成的,所有的对象通过彼此的合作,最终实现系统的业务逻辑. ...