opencv 学习总结
来源:互联网 发布:数据安全系统 编辑:程序博客网 时间:2024/06/05 02:13
1. Mat to IplImage* 的方法:
#include <opencv2/opencv.hpp>#include <iostream>#include <string>#include <vector>#include "Chroma.h"#include "cv.h"#include "highgui.h"using namespace concurrency;using namespace concurrency::fast_math;using namespace cv;using namespace std;void main(int argc, char ** argv){Mat frame_dest = imread("bule.jpg");IplImage *lplImage_dest = &IplImage(frame_dest);}
2. 取像素点的值,或者设置像素点的值
#include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/core/core.hpp> #include <opencv2/opencv.hpp>#include <iostream>#include <string>#include <vector>#include "Chroma.h"#include "cv.h"#include "highgui.h"using namespace concurrency;using namespace concurrency::fast_math;using namespace cv;using namespace std;void main(int argc, char ** argv){Mat _src_frame = imread("bule.jpg");Mat _background_frame = imread("red.jpg");Mat frame_YCbCr;IplImage *lplImage_src = &IplImage(_src_frame);IplImage *lplImage_background = &IplImage(_background_frame);for (int i = 0; i < row; i++){for (int j = 0; j < col; j++){if(i*j>50){CV_IMAGE_ELEM(lplImage_background, unsigned char, i, j * 3 + 0) = _src_frame.at<Vec3b>(i, j).val[0];CV_IMAGE_ELEM(lplImage_background, unsigned char, i, j * 3 + 1) = _src_frame.at<Vec3b>(i, j).val[1];CV_IMAGE_ELEM(lplImage_background, unsigned char, i, j * 3 + 2) = _src_frame.at<Vec3b>(i, j).val[2];}}}}
#include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/core/core.hpp> #include <opencv2/opencv.hpp>#include <iostream>#include <string>#include <vector>#include "Chroma.h"#include "cv.h"#include "highgui.h"using namespace concurrency;using namespace concurrency::fast_math;using namespace cv;using namespace std;void main(int argc, char ** argv){Mat frame_src = imread("bule.jpg");Rect rect(col / 2, row/2, 300, 200);Mat partImg = frame_src(rect);imwrite("part_image.jpg", partImg);}
4. 高斯滤波和颜色空间转换
#include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/core/core.hpp> #include <opencv2/opencv.hpp>#include <iostream>#include <string>#include <vector>#include "Chroma.h"#include "cv.h"#include "highgui.h"using namespace concurrency;using namespace concurrency::fast_math;using namespace cv;using namespace std;void main(int argc, char ** argv){Mat _src_frame = imread("bule.jpg");Mat frame_YCbCr;IplImage *lplImage_src = &IplImage(_src_frame);int row = _src_frame.rows;int col = _src_frame.cols;GaussianBlur(_src_frame, frame_GaussianBlur, Size(5, 5), 0, 0);cvtColor(frame_GaussianBlur, frame_YCbCr, CV_BGR2YCrCb);for (int i = 0; i < row; i++){for (int j = 0; j < col; j++){Cb_value = frame_YCbCr.at<Vec3b>(i, j).val[1];Cr_value = frame_YCbCr.at<Vec3b>(i, j).val[2];}}}
</pre><pre>5. 图片加水印
#include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/core/core.hpp> #include <opencv2/opencv.hpp>#include <iostream>#include <string>#include <vector>#include "Chroma.h"#include "cv.h"#include "highgui.h"using namespace concurrency;using namespace concurrency::fast_math;using namespace cv;using namespace std;void cvText(IplImage* img, const char* text, int x, int y){CvFont font;double hscale = 1.0;double vscale = 1.0;int linewidth = 2;cvInitFont(&font, CV_FONT_HERSHEY_SIMPLEX | CV_FONT_ITALIC, hscale, vscale, 0, linewidth);CvScalar textColor = cvScalar(0, 255, 255);CvPoint textPos = cvPoint(x, y);cvPutText(img, text, textPos, &font, textColor);}void main(int argc, char **argv){ Mat frame_background = imread("bule.jpg");lplImage_background = &IplImage(frame_background);CvFont font;cvInitFont(&font, CV_FONT_HERSHEY_COMPLEX, 1, 1, 0, 2, 8);cvPutText(lplImage_background, "www.Hello.com!", cvPoint(120, 50), &font, CV_RGB(0, 255, 0));imwrite("water_cover.jpg", frame_background);}
0 0
- OpenCV学习笔记总结
- opencv 学习总结
- opencv学习(7)----opencv学习总结
- OpenCV学习总结(一)
- 学习OpenCV的一些总结
- 【OpenCV学习】矩阵操作总结
- OpenCV学习_1和总结
- 【OpenCV学习】矩阵操作总结
- opencv颜色识别学习总结
- opencv摄像头标定学习总结
- opencv形状识别学习总结
- 1.7~1.9opencv学习总结
- opencv形状识别学习总结
- OpenCV学习总结---自己总结版
- OpenCV学习——矩阵操作总结
- OpenCV学习——矩阵操作总结
- OpenCV图像腐蚀的学习总结
- Opencv学习总结1-背景建模
- AngularJS学习笔记
- 菜鸟php的第一个博客
- HTML 入门
- 强连通分量,拓扑序
- hdu 1269 迷宫城堡 强连通分量
- opencv 学习总结
- 【论文阅读】Deep Compression: Compressing Deep Neural Networks with Pruning, Trained Quantization and Huff
- Caused by: android.content.res.Resources$NotFoundException: File res/drawable/abc_vector_test.xml fr
- POJ 1986 裸的LCA
- js直接在页面展示时间
- AVL树的旋转操作 图解 最详细
- hdu 4135 Co-Prime 容斥入门
- Gradle构建系统
- Hadoop元数据namenode的高可用原理