09 2011 档案
OpenCV_ 滑动条模拟按钮
摘要:HighGUI没有显示提供任何形式的按钮,可以使用只有两个状态的滑动条来代替按钮。View Code 1 int g_switch_value=0; 2 void switch_on_function() 3 { 4 5 } 6 void switch_off_function() 7 { 8 9 }10 11 void switch_callback(int position)12 {13 if(position==0)14 switch_off_function();15 else16 switch_on_function();17 ... 阅读全文
posted @ 2011-09-30 16:26 Ming明、 阅读(1183) 评论(0) 推荐(0) 编辑
OpenCV_用鼠标在窗口画方形
摘要:View Code 1 void my_mouse_callback(int event,int x,int y,int flags,void* param); 2 3 CvRect box; 4 5 bool drawing_box=false; 6 7 // a little subroutine to draw a box on to an image 8 void draw_box(IplImage* img,CvRect rect) 9 {10 cvRectangle(img,cvPoint(box.x,box.y),cvPoint(box.x+box.width,b... 阅读全文
posted @ 2011-09-30 15:54 Ming明、 阅读(2112) 评论(0) 推荐(0) 编辑
OpenCV_Add方法
摘要:View Code 1 //ROI的蓝色通道增加150灰度值效果 2 IplImage* src; 3 if((src=cvLoadImage("fruit.jpg",1))!=0) 4 { 5 int x=10; 6 int y=20; 7 int width=50; 8 int height=100; 9 int add=150;10 cvSetImageROI(src,cvRect(x,y,width,height));11 cvAddS(src,c... 阅读全文
posted @ 2011-09-30 15:27 Ming明、 阅读(1604) 评论(0) 推荐(0) 编辑
OpenCV--用读取矩阵,访问图像数据
摘要:View Code 1 int _tmain(int argc,_TCHAR* argv[]) 2 { 3 //用固定数据创建一个矩阵 4 float vals[]={0.664,-0.500,0.500,0.866}; 5 CvMat rotmat; 6 cvInitMatHeader(&rotmat,2,2,CV_32FC1,vals); 7 int number = cvGetDims(&rotmat,0); 8 CvMat* mat = cvCreateMat(5,5,CV_32FC1); 9 //用简单方法对矩阵数据存取。10... 阅读全文
posted @ 2011-09-29 19:33 Ming明、 阅读(4558) 评论(0) 推荐(1) 编辑
OpenCV_avi读入视频
摘要:View Code 1 int _tmain(int argc, _TCHAR* argv[]) 2 { 3 CvCapture* capture=0; 4 //读入视频文件 5 capture = cvCreateFileCapture("tree.avi"); 6 if(!capture) 7 return -1; 8 //将下一帧视频文件载入内存 9 IplImage *bgr_frame = cvQueryFrame(capture);10 11 //获取capture的各种属性12 //打开一个... 阅读全文
posted @ 2011-09-29 19:17 Ming明、 阅读(592) 评论(0) 推荐(0) 编辑
OpenCV_累加一个三通道矩阵中的所有元素
摘要:View Code 1 //累加一个三通道矩阵中的所有元素 2 float sum(const CvMat* mat) 3 { 4 float s=0.0f; 5 for(int row=0;row<mat->rows;row++) 6 { 7 const float* prt=(const float*)(mat->data->ptr+row*mat->step); 8 for (int col=0;col<mat->cols;col++) 9 {10 s+=*prt++;11 ... 阅读全文
posted @ 2011-09-29 16:29 Ming明、 阅读(1107) 评论(0) 推荐(0) 编辑
OpenCV__Canny边缘检测和缩放(译)
摘要:View Code 1 // opencvdemo.cpp : Defines the entry point for the console application. 2 // 3 #include "stdafx.h" 4 5 #ifdef _CH_ 6 #pragma package <opencv> 7 #endif 8 9 #ifndef _EiC10 #include "cv.h"11 #include "highgui.h"12 #endif13 14 IplImage * in;15 16 //缩放函数17 阅读全文
posted @ 2011-09-29 10:30 Ming明、 阅读(874) 评论(0) 推荐(0) 编辑
Canny边缘检测源码与图像结果(OpenCV2.0)
摘要:View Code 1 #include "stdafx.h" 2 #include "cv.h" 3 #include "cxcore.h" 4 #include "highgui.h" 5 #ifdef _CH_ 6 #pragma package <opencv> 7 #endif 8 #ifndef _EiC 9 #include "cv.h"10 #include "highgui.h"11 #endif12 char wndname[] = " 阅读全文
posted @ 2011-09-29 10:01 Ming明、 阅读(1776) 评论(0) 推荐(0) 编辑