I am working on a project which involves hand gesture recognition.I have to recognize the hand gesture and identify which letter of alphabet it represents.I am able to detect the skin using HSV color space.I have a video of all letters hand gestures and images of all letters hand gestures.Now I have to find which gesture represents which letter of alphabet.I need to know how to compare the gestures from the each frame of video with the image gestures.I am new to opencv ,please someone help me.This is my code
#include <opencv2\opencv.hpp>
using namespace cv;
using std::cout;
/*--------------- SKIN SEGMENTATION ---------------*/
int main() {
VideoCapture cap("E:\\videotest.mp4");
if (!cap.isOpened())
{// check if we succeeded
printf("coundnotoepn");
return -1;
}
Mat3b frame;
while (cap.read(frame)){
/* THRESHOLD ON HSV*/
cvtColor(frame, frame, CV_BGR2HSV);
GaussianBlur(frame, frame, Size(7, 7), 1, 1);
medianBlur(frame, frame, 15);
for (int r = 0; r<frame.rows; ++r){
for (int c = 0; c<frame.cols; ++c)
// 0<H<0.25 - 0.15<S<0.9 - 0.2<V<0.95
if ((frame(r, c)[0]>5) && (frame(r, c)[0] < 17) && (frame(r, c)[1]>38) && (frame(r, c)[1]<250) && (frame(r, c)[2]>51) && (frame(r, c)[2]<242)); // do nothing
else for (int i = 0; i<3; ++i) frame(r, c)[i] = 0;
}
/* BGR CONVERSION AND THRESHOLD */
Mat1b frame_gray;
cvtColor(frame, frame, CV_HSV2BGR);
cvtColor(frame, frame_gray, CV_BGR2GRAY);
threshold(frame_gray, frame_gray, 60, 255, CV_THRESH_BINARY);
morphologyEx(frame_gray, frame_gray, CV_MOP_ERODE, Mat1b(3, 3, 1), Point(-1, -1), 3);
morphologyEx(frame_gray, frame_gray, CV_MOP_OPEN, Mat1b(7, 7, 1), Point(-1, -1), 1);
morphologyEx(frame_gray, frame_gray, CV_MOP_CLOSE, Mat1b(9, 9, 1), Point(-1, -1), 1);
medianBlur(frame_gray, frame_gray, 15);
// imshow("Threshold", frame_gray);
cvtColor(frame, frame, CV_BGR2HSV);
resize(frame, frame, Size(), 0.5, 0.5);
imshow("Video", frame);
Mat3b image;
image = imread("E:/hand.jpg", CV_LOAD_IMAGE_COLOR); // Read the file
if (!image.data) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl;
return -1;
}
cvtColor(image, image, CV_BGR2HSV);
//printf("%d", image(2, 3)[5]);
//resize(image,image, Size(), 0.5, 0.5);
namedWindow("Display window", WINDOW_AUTOSIZE);// Create a window for display.
imshow("Display window", image); // Show our image ins
waitkey(1);
}