[ADD] contour of hand in calibration screen
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
|
||||
namespace computervision
|
||||
{
|
||||
|
||||
FingerCount::FingerCount(void) {
|
||||
color_blue = Scalar(255, 0, 0);
|
||||
color_green = Scalar(0, 255, 0);
|
||||
@@ -35,9 +36,6 @@ namespace computervision
|
||||
if (input_image.channels() != 1)
|
||||
return contours_image;
|
||||
|
||||
vector<vector<Point>> contours;
|
||||
vector<Vec4i> hierarchy;
|
||||
|
||||
findContours(input_image, contours, hierarchy, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
|
||||
|
||||
// we need at least one contour to work
|
||||
@@ -45,7 +43,7 @@ namespace computervision
|
||||
return contours_image;
|
||||
|
||||
// find the biggest contour (let's suppose it's our hand)
|
||||
int biggest_contour_index = -1;
|
||||
biggest_contour_index = -1;
|
||||
double biggest_area = 0.0;
|
||||
|
||||
for (int i = 0; i < contours.size(); i++) {
|
||||
@@ -156,6 +154,11 @@ namespace computervision
|
||||
return contours_image;
|
||||
}
|
||||
|
||||
void FingerCount::DrawHandContours(Mat& image)
|
||||
{
|
||||
drawContours(image, contours, biggest_contour_index, color_green, 2, 8, hierarchy);
|
||||
}
|
||||
|
||||
int FingerCount::getAmountOfFingers()
|
||||
{
|
||||
return amount_of_fingers;
|
||||
|
||||
@@ -31,7 +31,15 @@ namespace computervision
|
||||
*/
|
||||
int getAmountOfFingers();
|
||||
|
||||
void DrawHandContours(Mat& image);
|
||||
|
||||
private:
|
||||
|
||||
int biggest_contour_index;
|
||||
vector<vector<Point>> contours;
|
||||
vector<Vec4i> hierarchy;
|
||||
|
||||
|
||||
// colors to use
|
||||
Scalar color_blue;
|
||||
Scalar color_green;
|
||||
@@ -115,5 +123,7 @@ namespace computervision
|
||||
* @param with_numbers if the numbers should be drawn with the points
|
||||
*/
|
||||
void drawVectorPoints(Mat image, vector<Point> points, Scalar color, bool with_numbers);
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
@@ -64,7 +64,7 @@ namespace computervision
|
||||
DrawHandMask(&camera_frame);
|
||||
string hand_text = fingers_amount > 0 ? "open" : "closed";
|
||||
putText(camera_frame, hand_text, Point(10, 75), FONT_HERSHEY_PLAIN, 2.0, Scalar(255, 0, 255), 3);
|
||||
|
||||
finger_count.DrawHandContours(camera_frame);
|
||||
hand_calibrator.DrawHandCalibrationText(camera_frame);
|
||||
imshow("camera", camera_frame);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user