findContours异常问题(opencv3.1+vs2013)
来源:互联网 发布:查端口被占用 编辑:程序博客网 时间:2024/06/05 06:20
1. VS2013环境配置
1.1 配置opencv3.1环境
1)配置包含目录和库目录
2)配置opencv依赖库
1.2 opencv3.1运行模式配置
配置运行库:
1)外部连接依赖为:opencv_world310.lib:(Release模式)
则运行库配置为/MT或/MD才能正常工作
2) 外部连接依赖为:opencv_world310d.lib:(Debug模式)
则运行库配置为/MTd或/MDd才能正常工作
MT:MultiThread(static link) ibcmt.lib
MD:MultiThread(dynamic link) msvert.lib
2. 示例代码
#include <opencv2/opencv.hpp>#include <iostream>struct Component{ cv::Rect boundingBox; double area; double circularity;};int main(){ // Create a small image with a circle in it. cv::Mat image(256, 256, CV_8UC3, cv::Scalar(0, 0, 0)); cv::circle(image, cv::Point(80, 110), 42, cv::Scalar(255,127, 63), -1); // Find canny edges. cv::Mat cannyEdges; cv::Canny(image, cannyEdges, 80, 60); // Show the images. cv::imshow("img", image); cv::imshow("cannyEdges", cannyEdges); // Find the contours in the canny image. cv::vector<cv::Vec4i> hierarchy; // "Each contour is stored as a vector of points." // http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html#findcontours typedef cv::vector<cv::vector<cv::Point> > TContours; TContours contours; cv::findContours(cannyEdges, contours, hierarchy, CV_RETR_CCOMP, CV_CHAIN_APPROX_NONE); // cannyEdges is destroyed after calling cv::findContours // Print number of found contours. std::cout << "Found " << contours.size() << " contours." << std::endl; // Convert contours to Components. typedef cv::vector<Component> TComponents; TComponents components; for (TContours::const_iterator it( contours.begin() ); it != contours.end(); ++it) { Component c; c.area = cv::contourArea(*it); c.boundingBox = cv::boundingRect(*it); c.circularity = 0.0; // Insert whatever you mean by circularity; components.push_back(c); } for (TComponents::const_iterator it( components.begin() ); it != components.end(); ++it) std::cout << it->area << std::endl; // and whatever you want. // Wait for user input. cv::waitKey();}
3. 出错原因
1) VS版本与OpenCV VS版本不匹配
2) Opencv与Debug与Release与VS工程的配置不一致
0 0
- findContours异常问题(opencv3.1+vs2013)
- VS2013 配置OpenCV3.1
- opencv3.0 findContours出现错误,内存泄漏问题
- opencv3.2 findContours debuge模式下触发断点问题
- opencv3.0 + VS2010中FindContours()函数崩溃问题
- opencv 调用findContours异常的问题
- TLD+OpenCV3+VS2013+win8.1
- VS2013永久配置opencv3.1
- CMake+VS2013编译OpenCV3.1
- opencv3.1contrib+VS2013配置
- 基于opencv3.2.0版本FindContours()中method参数导致程序异常解决
- vs2013下配置opencv3.0的问题
- OPENCV3.0+VS2013配置问题+cmake配置
- python opencv3 —— findContours
- opencv Findcontours异常
- VS2013+QT5+opencv3.1显示摄像头
- 1_Configure OpenCV3.2 for VS2013
- win7(X64)+VS2013+OpenCV3.1环境配置
- vector与结构体结合的简单应用
- 实现一个函数,打印乘法口诀表,口诀表的行数和列数自己指定,输入多少打印几乘几的乘法表
- 使用函数实现两个数的交换。
- 游戏排行榜算法设计实现比较
- 实现一个函数判断year是不是闰年。
- findContours异常问题(opencv3.1+vs2013)
- mybatis与hibernate区别
- 创建一个数组, 实现初始化数组、清空数组、完成数组元素的逆置。
- 实现一个函数,判断一个数是不是素数。
- iOS开发 - 第02篇 - UI进阶 - 08 - 私人通讯录
- 【好玩的棋盘游戏】编写一个玩家操作的函数和电脑能够操作的两人棋盘游戏,哪边有三个相连的胜出
- 【C语言】编写一个折半查找函数
- 在做统计图时候遇见的问题
- 控制ViewPager的切换速度