资源简介
文件包括测试图片和svm颜色分类的cpp文件,我用的是vs2013+opencv3.4.1版本,有两张测试图片。其中训练集数据采取的是test.png。

代码片段和文件信息
/*
这个是完整版本,添加标签,分类
*/
#include
#include
#include
#include
#include
#include
using namespace std;
using namespace cv;
using namespace cv::ml;
void on_mouse(int event int x int y int flags void* ustc); //鼠标取样本点
void scale_Sampling(const Mat &src Mat &dst double Ratio);
int main(int argc char *argv[])
{
long red_numb = 0 yellow_numb = 0 green_numb = 0 blue_numb = 0 back_numb = 0;
//------------------------坐标信息----------------------//
//红色:x245y211
//绿色:x500y710
//黄色:x770y60
//蓝色:x1040y490
//背景:x13y246
int redx = 245 redy = 211;
int greenx = 500 greeny = 710;
int yellowx = 770 yellowy = 60;
int bluex = 1040 bluey = 490;
int backx = 13 backy = 150;
int radi = 11;
Mat arry[10];
String a = “C:/Users/ncutl/Desktop/siasuna.png“;
Mat ori_image = imread(a);
Point c(0 0) b(128 100);
Rect rect1(c b);
Mat roi1;
ori_image(rect1).copyTo(roi1); // copy the region rect1 from the image to roi1
imshow(“1“ roi1);
//namedWindow(“ori“ CV_WINDOW_NORMAL);
//imshow(“ori“ ori_image);
//setMouseCallback(“ori“ on_mouse 0);
/*Mat Red_Mat(50 50 CV_8UC3 Scalar(0 0 255));
cout << endl << Red_Mat << endl << endl;
uchar *p = Red_Mat.data;
//waitKey(0);
Mat T3_M(Red_Mat.rows*Red_Mat.cols 3 CV_8UC1 p);//转化成一维
cout << “T3_M: “ < */
//--------------------红色训练集---------------------//
//rectangle(red cv::Rect(0 0 200 150) cv::Scalar(255 0 0) 10);
Mat red_roi_uf(ori_image Rect(redx redy 100 100));
Mat red_roi;
DWORD tim1 = GetTickCount();
medianBlur(red_roi_uf red_roi radi);
DWORD tim2 = GetTickCount();
cout << tim2 - tim1 << endl;
//cout << red_roi << endl << endl;
Mat red_roi_convert;
red_roi.convertTo(red_roi_convert CV_32FC1);
Mat red_roi_data(red_roi_convert.rows*red_roi_convert.cols 3 CV_32FC1 red_roi_convert.data);
//cout << red_roi_data << endl << endl;
Mat red_label = Mat(red_roi_convert.rows*red_roi_convert.cols 1 CV_32SC1 Scalar::all(1));
//cout << red_label << endl << endl;
imshow(“红色“ red_roi);
//-------------------黄色训练集-----------------//
Mat yellow_roi_uf(ori_image Rect(yellowx yellowy 100 100));
Mat yellow_roi;
tim1 = GetTickCount();
medianBlur(yellow_roi_uf yellow_roi radi);
tim2 = GetTickCount();
cout << tim2 - tim1 << endl;
//cout << red_roi << endl << endl;
Mat yellow_roi_convert;
yellow_roi.convertTo(yellow_roi_convert CV_32FC1);
Mat yellow_roi_data(yellow_roi_convert.rows*yellow_roi_convert.cols 3 CV_32FC1 yellow_roi_convert.data);
//cout << yellow_roi_data << endl << endl;
Mat yellow_label = Mat(yellow_roi_convert.rows*yellow_roi_convert.cols 1 CV_32SC1 Scalar::all(2));
imshow(“黄色“ yellow_roi);
//------------------------绿色训练集---------------//
Mat green_roi_uf(ori
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2088502 2018-06-13 15:35 22.png
文件 2196774 2018-05-11 11:40 siasuna.png
文件 10102 2018-05-23 14:37 svmtest.cpp
相关资源
- 基于OpenCV的数字识别468815
- 使用opencv去掉二值化图像中黑色面积
- opencv环境配置
- win10 64位下编译的opencv4.5.5库,opencv
- 基于蚁群算法优化SVM的瓦斯涌出量预
- 基于模糊聚类和SVM的瓦斯涌出量预测
- 基于CAN总线与ZigBee的瓦斯实时监测及
- SVM-Light资料,使用说明
- NVIDIAOpticalFlowSDK-79c6cee80a2df9a196f20afd6
- 果蝇算法融合SVM的开采沉陷预测模型
- opencv_contrib-3.4.0.zip
- BoW|Pyramid BoW+SVM进行图像分类
- opencv2.4.9源码分析——SIFT
- 基于libsvm的图像分割代码
- 用两个摄像头实现,双目标定,双目
- 基于SVM及两类运动想象的多通道特征
- 小波包和SVM在轴承故障识别中的应用
- 林智仁教授最新版本LibSVM工具箱
- 台湾林教授的支持向量机libsvm
- opencv_traincascade训练分类器,手势识别
- opencv3.0交叉编译用parallel.cpp
- 新闻分类语料
- 基于opencv的图像识别识别图像中的色
- 基于openCV的识别特定颜色区域
- 基于OpenCV的分水岭算法实现
- QT+opencv+OCR 身份证号码,银行卡号识别
- opencv视频特定颜色区域识别
- 把RGB转换为HSV和HSI然后根据黄色和蓝
- libsvm-3.20
- opencv视觉测距
评论
共有 条评论