91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

本文對(duì)http://docs.opencv.org/doc/tutorials/imgproc/shapedescriptors/hull/hull.html#hull以及http://www.intorobotics.com/9-opencv-tutorials-hand-gesture-detection-recognition/兩個(gè)部分進(jìn)行合并。并加入自己的圖像預(yù)處理,包括采集、去背景和二值化。實(shí)現(xiàn)了手掌的特征點(diǎn)提取。

資源截圖

代碼片段和文件信息

#include?“stdafx.h“
#include?
#include?
//?TODO:?reference?additional?headers?your?program?requires?here
#include?
#include????//?for?strings
#include???//?for?controlling?float?print?precision
#include???//?string?to?number?conversion
#include?
#include??
#include?
#include?
#include?

#include?“opencv2/core/core.hpp“
#include?“opencv2/imgproc/imgproc.hpp“
#include?“opencv2/highgui/highgui.hpp“
#include?“opencv2/objdetect/objdetect.hpp“
#include?“opencv2/video/video.hpp“


using?namespace?std;??
using?namespace?cv;

#define?PI?3.14159265




std::clock_t clock_start;?//start?clock
double time_consume;?//?time?consume

cv::Mat?raw_frame; //raw?image
cv::Mat?gray_frame; //my_gray_frame
cv::Mat segmented_frame; //image?after?segmentation
cv::Mat?ROI_frame;

cv::Mat?src;
cv::Mat?src_gray;
?cv::Mat?drawing;
?
?cv::Mat?poly_frame;
?cv::Mat?convex_frame;
?std::vector?defects;
std::vector?real_defects;
std::vector?convexhull;
VideoCapture?capture_single;


bool?capture_image?(int?id); //get?raw?frame
void?segment_image?(int?gray_lower_bound?int?gray_upper_bound); //segmentation
bool?substract_background?(); //get?rid?of?background?noise

void?draw_contour(Mat?frame?std::vector?contour?Scalar?scalar);?//draw?contour?on?a?frame
int?calc_point_angle(cv::Point?point?cv::Point?center);?//calculate?the?point?angle?based?on?the?center?point


int?calc_points_dist?(cv::Point?point1?cv::Point?point2)
{
int?x_delta=point1.x?-?point2.x;
int?y_delta=point1.y?-?point2.y;
int?dist=(int)sqrt((double)(x_delta*x_delta?+?y_delta*y_delta));
return?dist;
}
int?calc_point_angle(cv::Point?point?cv::Point?center)
{
//calculate?two?point?dist
int?angle?=?0;
float?sin_value?=?0.0;
int?dist = calc_points_dist(point?center);

if(dist==0)?return?-1;

#ifdef?DEBUG
// printf(“dist?%d\n“dist);
#endif

//calculate?sin?value?based?on?two?points
sin_value = ((float)point.y-?(float)center.y)/(float)dist;

if(sin_value>1) sin_value = 1;?//exception?handling

//get?value
angle = (int)((double)std::asin(sin_value)*180/PI);

#ifdef?DEBUG
// printf(“sin?value?%f\n“sin_value);
// printf(“my?angle?%d\n“angle);
#endif

if(point.x?>?center.x){
if(point.y? {
//re?calculate?the?angle
angle = 360+angle;
}
}
else
{
angle = 180?-?angle;
}

return?angle;
}

bool?capture_image(int?id){


capture_single.open(id);

//open?fail
if(!capture_single.isOpened())?
{
printf(“Error:?cannot?open?camera!“);
return?false;
}

}


void?segment_image(int?gray_lower_bound?int?gray_upper_bound){
cv::cvtColor(raw_frame?gray_frame?CV_BGR2GRAY);
//gray_lower_bound?=?pre_cut(raw_frame);
gray_lower_bound?=?100;
cv::inRange(gray_frame?gray_lower_bound?gray_upper_bound?segmented_frame);
/

評(píng)論

共有 條評(píng)論