例子 – 青春部落,流年似水 http://www.youthtribe.com 青春是一场远行,总记不起来时的路。 Thu, 07 Aug 2014 12:13:19 +0000 zh-CN hourly 1 https://wordpress.org/?v=6.1.6 例子 – 青春部落,流年似水 http://www.youthtribe.com/archives/1282 http://www.youthtribe.com/archives/1282#respond Thu, 07 Aug 2014 12:13:19 +0000 http://www.youthtribe.com/?p=1282 vc操作mysql的典型例子
1.包含文件

#include "mysql.h"

2.初始化数据库

	//开始链接数据库
	//MYSQL mysql;//定义成全局的
	mysql_init(&mysql);
	mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, "utf-8"); 

	if(!mysql_real_connect(&mysql,"localhost","user","password","user_db",3306,NULL,0))
	{
		AfxMessageBox("数据库连接失败");
	}
	else
	{
		//MessageBox("链接数据库成功!");
	}

3.插入数据

	//添加到数据库
	
	CString strSQL = "insert into xbzq.group values(NULL,'test');";
	const char * q =strSQL;
	mysql_query(&mysql,q);

4.读出数据

	strsql = "select * from sentence_lib where id = " + m_nId;
	mysql_query(&mysql,strsql);
	res = mysql_store_result(&mysql);
	MYSQL_ROW row=NULL;
	row = mysql_fetch_row(res);
	strpassage = strpassage+row[1];



/////////////////////

	//从数据库中随机取出一个句子
	CString strsql="select * from sentence_lib";
	const char * q =strsql;
	mysql_query(&mysql,q);

	MYSQL_RES *res = mysql_store_result(&mysql);

	//mysql_use_result(MYSQL *mysql);

	int nRow = res->row_count;//得到组文章用的句子库的数量
	
]]>
http://www.youthtribe.com/archives/1282/feed 0
例子 – 青春部落,流年似水 http://www.youthtribe.com/archives/913 http://www.youthtribe.com/archives/913#comments Wed, 10 Jul 2013 13:49:41 +0000 http://www.youthtribe.com/?p=913 先来看opencv函数 cvHoughCircles 的说明:

函数:CvSeq *cvHoughCircles(CvArr *image,void *circle_storage,int method,double dp,double min_dist,double param1,double param2,int min_radius,int max_radius)

下边是参数说明:

image:输入8bit(灰度)图像,其内容可被函数所改变
circle_storage:检测到的圆存储仓,可以是内存存储仓 (此种情况下,一个线段序列在存储仓中被创建,并且由函数返回)或者是包含圆参数的特殊类型的具有单行/单列的CV_32FC3型矩阵(CvMat*). 矩阵头为函数所修改,使得它的 cols/rows 将包含一组检测到的圆。如果 circle_storage 是矩阵,而实际圆的数目超过矩阵尺寸,那么最大可能数目的圆被返回,每个圆由三个浮点数表示:圆心坐标(x,y)和半径.).
method:Hough 变换方式,目前只支持CV_HOUGH_GRADIENT, which is basically 21HT, described in [Yuen03].
dp:寻找圆弧圆心的累计分辨率,这个参数允许创建一个比输入图像分辨率低的累加器。(这样做是因为有理由认为图像中存在的圆会自然降低到与图像宽高相同数量的范畴)。如果dp设置为1,则分辨率是相同的;如果设置为更大的值(比如2),累加器的分辨率受此影响会变小(此情况下为一半)。dp的值不能比1小。
min_dist:该参数是让算法能明显区分的两个不同圆之间的最小距离。
param1:用于Canny的边缘阀值上限,下限被置为上限的一半。
param2:累加器的阀值。
The second method-specific parameter. In case of CV_HOUGH_GRADIENT it is accumulator threshold at the center detection stage. The smaller it is, the more false circles may be detected. Circles, corresponding to the larger accumulator values, will be returned first.
min_radius:最小圆半径。
max_radius:最大圆半径。
]]>
http://www.youthtribe.com/archives/913/feed 1