資源簡介
手勢指尖檢測算法c++實現(xiàn),使用膚色分割算法將手勢從復雜背景中分離出來,通過檢測手指指尖進行手指識別。

代碼片段和文件信息
#include?
#include?
#include?
#include?
int?minH?=?0?maxH?=?20?minS?=?30?maxS?=?150?minV?=?60?maxV?=?255;
cv::Mat?frame;
int?count?=?0;
float?innerAngle(float?px1?float?py1?float?px2?float?py2?float?cx1?float?cy1)
{
float?dist1?=?std::sqrt(??(px1-cx1)*(px1-cx1)?+?(py1-cy1)*(py1-cy1)?);
float?dist2?=?std::sqrt(??(px2-cx1)*(px2-cx1)?+?(py2-cy1)*(py2-cy1)?);
float?Ax?Ay;
float?Bx?By;
float?Cx?Cy;
//find?closest?point?to?C??
//printf(“dist?=?%lf?%lf\n“?dist1?dist2);??
Cx?=?cx1;
Cy?=?cy1;
if(dist1? {
Bx?=?px1;
By?=?py1;
Ax?=?px2;
Ay?=?py2;
}else{
Bx?=?px2;
By?=?py2;
Ax?=?px1;
Ay?=?py1;
}
float?Q1?=?Cx?-?Ax;
float?Q2?=?Cy?-?Ay;
float?P1?=?Bx?-?Ax;
float?P2?=?By?-?Ay;
float?A?=?std::acos(?(P1*Q1?+?P2*Q2)?/?(?std::sqrt(P1*P1+P2*P2)?*?std::sqrt(Q1*Q1+Q2*Q2)?)?);
A?=?A*180/CV_PI;
return?A;
}
void?CallbackFunc(int?event?int?x?int?y?int?flags?void*?userdata)
{
cv::Mat?RGB?=?frame(cv::Rect(x?y?1?1));
cv::Mat?HSV;
cv::cvtColor(RGB?HSV?CV_BGR2HSV);
cv::Vec3b?pixel?=?HSV.at(0?0);
if?(event?==?cv::EVENT_LBUTTONDBLCLK)?//?on?double?left?clcik
{
std::cout?<“Click“?< int?h?=?pixel.val[0];
int?s?=?pixel.val[1];
int?v?=?pixel.val[2];
if?(count?==?0)
{
minH?=?h;
maxH?=?h;
minS?=?s;
maxS?=?s;
minV?=?v;
maxV?=?v;
}
else
{
if?(h? {
minH?=?h;
}
else?if?(h?>?maxH)
{
maxH?=?h;
}
if?(s? {
minS?=?s;
}
else?if?(s?>?maxS)
{
maxS?=?s;
}
if?(v? {
minV?=?v;
}
else?if?(v?>?maxV)
{
maxV?=?v;
}
}
count++;
}
std::cout?<}
int?main()
{
cv::VideoCapture?cap(0);
const?char*?windowName?=?“Fingertip?detection“;
cv::namedWindow(windowName);
cv::setMouseCallback(windowName?CallbackFunc?NULL);
int?inAngleMin?=?200?inAngleMax?=?300?angleMin?=?180?angleMax?=?359?lengthMin?=?10?lengthMax?=?80;
cv::createTrackbar(“Inner?angle?min“?windowName?&inAngleMin?360);
cv::createTrackbar(“Inner?angle?max“?windowName?&inAngleMax?360);
cv::createTrackbar(“Angle?min“?windowName?&angleMin?360);
cv::createTrackbar(“Angle?max“?windowName?&angleMax?360);
cv::createTrackbar(“Length?min“?windowName?&lengthMin?100);
cv::createTrackbar(“Length?max“?windowName?&lengthMax?100);
while?(1)
{
cap?>>?frame;
cv::Mat?hsv;
cv::cvtColor(frame?hsv?CV_BGR2HSV);
cv::inRange(hsv?cv::Scalar(minH?minS?minV)?cv::Scalar(maxH?maxS?maxV)?hsv);
//?Pre?processing
int?blurSize?=?5;
int?elementSize?=?5;
cv::medianBlur(hsv?hsv?blurSize);
cv::Mat?element?=?cv::getStructuringElement(cv::MORPH_ELLIPSE?cv::Size(2?*?elementSize?+?1?2?*?elementSize?+?1)?cv::Point(elementSize?elementSize
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????155656??2016-08-08?16:24??手勢指尖檢測\Fingertip?Detection?in?OpenCV?-?Tango?with?code.htm
?????文件????????999??2016-08-08?16:24??手勢指尖檢測\Fingertip?Detection?in?OpenCV?-?Tango?with?code_files\css
?????文件????????241??2016-08-08?16:24??手勢指尖檢測\Fingertip?Detection?in?OpenCV?-?Tango?with?code_files\css(1)
?????文件????????252??2016-08-08?16:24??手勢指尖檢測\Fingertip?Detection?in?OpenCV?-?Tango?with?code_files\css(2)
?????文件?????217705??2016-08-08?16:24??手勢指尖檢測\Fingertip?Detection?in?OpenCV?-?Tango?with?code_files\fingertip1.png
?????文件?????175774??2016-08-08?16:24??手勢指尖檢測\Fingertip?Detection?in?OpenCV?-?Tango?with?code_files\fingertip10.png
?????文件??????11147??2016-08-08?16:24??手勢指尖檢測\Fingertip?Detection?in?OpenCV?-?Tango?with?code_files\fingertip2.png
?????文件??????25362??2016-08-08?16:24??手勢指尖檢測\Fingertip?Detection?in?OpenCV?-?Tango?with?code_files\fingertip3.png
?????文件???????4315??2016-08-08?16:24??手勢指尖檢測\Fingertip?Detection?in?OpenCV?-?Tango?with?code_files\fingertip4.png
?????文件????1016899??2016-08-08?16:24??手勢指尖檢測\Fingertip?Detection?in?OpenCV?-?Tango?with?code_files\fingertip5.png
?????文件?????339959??2016-08-08?16:24??手勢指尖檢測\Fingertip?Detection?in?OpenCV?-?Tango?with?code_files\fingertip6.png
?????文件?????225033??2016-08-08?16:24??手勢指尖檢測\Fingertip?Detection?in?OpenCV?-?Tango?with?code_files\fingertip7.png
?????文件?????202695??2016-08-08?16:24??手勢指尖檢測\Fingertip?Detection?in?OpenCV?-?Tango?with?code_files\fingertip8.png
?????文件???????1113??2016-08-08?16:24??手勢指尖檢測\Fingertip?Detection?in?OpenCV?-?Tango?with?code_files\github.js
?????文件??????36312??2016-08-08?16:24??手勢指尖檢測\Fingertip?Detection?in?OpenCV?-?Tango?with?code_files\handangle.png
?????文件??????92629??2016-08-08?16:24??手勢指尖檢測\Fingertip?Detection?in?OpenCV?-?Tango?with?code_files\jquery.min.js
?????文件???????2475??2016-08-08?16:24??手勢指尖檢測\Fingertip?Detection?in?OpenCV?-?Tango?with?code_files\jXHR.js
?????文件???????7020??2016-08-08?16:24??手勢指尖檢測\Fingertip?Detection?in?OpenCV?-?Tango?with?code_files\modernizr-2.0.js
?????文件???????8357??2016-08-08?16:24??手勢指尖檢測\Fingertip?Detection?in?OpenCV?-?Tango?with?code_files\octopress.js
?????文件??????19195??2016-08-08?16:24??手勢指尖檢測\Fingertip?Detection?in?OpenCV?-?Tango?with?code_files\screen.css
?????文件????????269??2016-08-08?16:24??手勢指尖檢測\Fingertip?Detection?in?OpenCV?-?Tango?with?code_files\spoiler.js
?????文件???43581440??2016-11-21?15:05??手勢指尖檢測\ipch\opennixtionrgbd-1b81a9a\opennixtionrgbd-5e1143c6.ipch
?????文件???????1181??2013-04-29?15:48??手勢指尖檢測\OpenNIXtionRGBD\intrinsics.yml
?????文件???????5383??2016-08-08?16:21??手勢指尖檢測\OpenNIXtionRGBD\OpenNIXtionRGBD.cpp
?????文件???????4494??2016-08-04?17:22??手勢指尖檢測\OpenNIXtionRGBD\OpenNIXtionRGBD.vcxproj
?????文件????????964??2014-06-25?16:38??手勢指尖檢測\OpenNIXtionRGBD\OpenNIXtionRGBD.vcxproj.filters
?????文件????????299??2016-08-04?15:23??手勢指尖檢測\OpenNIXtionRGBD\OpenNIXtionRGBD.vcxproj.user
?????文件???????8406??2016-08-04?15:28??手勢指尖檢測\OpenNIXtionRGBD\results.log
?????文件????????912??2014-06-25?16:36??手勢指尖檢測\OpenNIXtionRGBD.sln
????..A..H.?????32256??2016-11-21?15:05??手勢指尖檢測\OpenNIXtionRGBD.suo
............此處省略8個文件信息
評論
共有 條評論