资源简介
文件包括测试图片和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
相关资源
- 使用PSO优化LSSVM
- QT OPENCV车牌识别 识别结果输出到Tex
- opencv3.2交叉编译移植笔记
- OpenCV人脸识别290071
- openCV库文件卷3
- opencv运动目标跟踪
- opencv基于颜色直方图进行模板图像匹
- 基于svm的中文文本分类系统
- 双目标定以及双目测距程序.rar
- OpenCV插件UE4
- opencv_world420.dll
- OpenCV 4.2.0 Visual Studio 2017 32位 版本
- OpenCV实现的图像2D转3D Image-2D-to-3D.ra
- SVM学习笔记+伪码.pdf
- 一幅图片中画两个矩形
- VS2015编译好的opencv3.4.1+contrib3.4.1
- 基于opencv的双目相机标定代码
- 图片合成视频OpenCV
- 视频人脸追踪
- opencv2410forMinGw
- Tesseract 4.0 for VS2015及OpenCV数字识别程
- Computer Vision with OpenCV3 and Qt5完整版
- pb模型转pbtxtopencv调用
- Computer Vision with OpenCV 3 and Qt5
- 基于hog+pca+svm行人检测源码
- Kmeans的opencv实现
- 基于VS2017+opencv3.4.3的立体匹配SGBM与
- 机器学习-Hog+SVM小狮子识别.zip
- OpenCV345_build_MinGW32bit
- Opencv+VS米粒图像处理实验源代码
评论
共有 条评论