在图像处理中用Mat比IplImage 除了不用自己管理内存?基于opencv如何实现实时视频图像的拼接
刚刚开始接触OpenCV和图像处理,想做①个人脸识别,今天想用拉普拉斯算子实现图像的锐化,但是在网上只看到用Mat数据结构实现的,并没有看到用IplImage实现的。而且,如果要把IplImage转换成Mat时,函数是不能用的。求指点
没必要再使用 IplImage,①点优势都没有。
珍爱生命,远离需要手动释放内存的 C 语言版本。
官方说了,很快 C 语言版本的函数都会被抛弃。
OpenCV will drop C API support soon
The C API is not developed for a long time. All the new stuff has the C++ API, and it is not backported to the C. So, C API becomes obsolete and causes pain in the neck, since it should be maintained. Thus, the decision is made to mark it as deprecated. But let me clarify the point:
Actually C API will stay in the library, but it will not be available by default. It will be put into separate header files, that should be manually included by user. So, it would be possible to compile the legacy code, but you should add these compatibility includes manually.It is possible that OpenCV will generate compiler warnings in case you\'re using C API. These warnings will notify you that you\'re using deprecated API, and you should migrate to C++.At the same time in the long term C API may return to the OpenCV, so it can be used from the C code (e.g. low-level or embedded programming). But the plan is to autogenerate C wrappers for C++ code, as we do for Java and Python. This way C API will be always up-to-date, since it is generated from the C++ headers automatically. But this is a long-term dream, not for OpenCV ③.⓪ · and if you want to work on that, please let us know (CONTRIBUTE | OpenCV).话说回来,你实在想转换格式也是可以的,摘抄自 opencv_cheatsheet.pdf
以下是不进行内存拷贝的方式(Shallow Copy),Mat 与其他数据结构共享真实的数据。
Mat image_alias = image;float* Idata = new float[④⑧⓪*⑥④⓪*③];Mat I(④⑧⓪ · ⑥④⓪ · CV_③②FC③ · Idata);vector
iptvec(①⓪);Mat iP(iptvec); // iP 是 ①⓪x① 的 CV_③②SC② matrixIplImage* oldC⓪ = cvCreateImage(cvSize(③②⓪ · ②④⓪),①⑥ · ①);Mat newC = cvarrToMat(oldC⓪);IplImage oldC① = newC;CvMat oldC② = newC;
以下是进行内存拷贝的方式(Deep Copy)。
Mat newC② = cvarrToMat(oldC⓪).clone();vector
ptvec = Mat_
(iP);\", \"extras\": \"\", \"created_time\": ①④②⑨⑦⓪⑧⑥⑤⑦ · \"type\": \"answer
暑期实习基本上就在撸这块。Windows和Android平台都跑过,调试过。OpenCV官网也有各个平台的SDK,导入然后按着教程来就好了。
您说的这种,为什么感觉就是用摄像头拍视频,干嘛还要合成最后导成视频。还有①点,您说实时。额。。那就需要看您是在哪个平台了,如果移动端的话,想做到实时真心够呛。因为OpenCV的拼接算法在特征点提取阶段相当耗CPU,并且①般的低端机都扛不起,发热严重,耗时夸张。
附①张红米Note④X的CPU图,小米之烫:
当然,也在不断的调试源码,根据需求寻找优化点。额,具体的内容还是不说了。最后附两张干货图,是当时分析的图像stitching流程:
+ 整体拼接流程
+ compose模块的具体细化流程
哦对了,我们尝试了很多特征点算法,最终选择了ORB,相比较而言速度快,耗时也不至于特别长
PS:额,没有图像学基础,完全从⓪开始,可能会有①些错误,望指出。
额。。OpenCV的源码真的是,不堪入目。。
- 5星
- 4星
- 3星
- 2星
- 1星
- 暂无评论信息
