Ask Your Question

Kevin Phytagoras's profile - activity

2014-01-27 05:57:54 -0600 asked a question How to specifically know the HSV value of an object from webcam

m working on a project that need HSV color threshold for color segmentation. i find the threshold using this function

IplImage* GetThresholdedImage(IplImage* imgHSV){       
    IplImage* imgThresh=cvCreateImage(cvGetSize(imgHSV),IPL_DEPTH_8U, 1);
    cvInRangeS(imgHSV, cvScalar(170,160,60), cvScalar(180,2556,256), imgThresh); 
    return imgThresh;
}

my problem is the color is often not detected when i run the project in the morning, noon or night. And i have to find the range manually and input it again in my code which is tiresome.

Is there any way to automatically find the color threshold of my object. Lets say i need to find red object.

Thank you for your attention. i waited for any of your response

2014-01-09 03:02:14 -0600 commented answer Template matching in webcam

how to acquisite the image from webcam ?

2014-01-08 15:50:24 -0600 asked a question Template matching in webcam

Hello there, i have a question.

i have a program that does simple template matching. My question is, i want to make the source from my webcam and the result is showed on my webcam. Here's my code

#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

int main() 
{
    cv::Mat ref = cv::imread("reference.png");
    cv::Mat tpl = cv::imread("template.png");
    if (ref.empty() || tpl.empty())
        return -1;

    cv::Mat gref, gtpl;
    cv::cvtColor(ref, gref, CV_BGR2GRAY);
    cv::cvtColor(tpl, gtpl, CV_BGR2GRAY);

    cv::Mat res(ref.rows-tpl.rows+1, ref.cols-tpl.cols+1, CV_32FC1);
    cv::matchTemplate(gref, gtpl, res, CV_TM_CCOEFF_NORMED);
    cv::threshold(res, res, 0.8, 1., CV_THRESH_TOZERO);

    while (true) 
    {
        double minval, maxval, threshold = 0.8;
        cv::Point minloc, maxloc;
        cv::minMaxLoc(res, &minval, &maxval, &minloc, &maxloc);

        if (maxval >= threshold)
        {
            cv::rectangle(
                ref, 
                maxloc, 
                cv::Point(maxloc.x + tpl.cols, maxloc.y + tpl.rows), 
                CV_RGB(0,255,0), 2
            );
            cv::floodFill(res, maxloc, cv::Scalar(0), 0, cv::Scalar(.1), cv::Scalar(1.));
        }
        else
            break;
    }

    cv::imshow("reference", ref);
    cv::waitKey();
    return 0;
}

Thank you for your attention. I wait for any of your response.

2013-12-01 06:00:00 -0600 received badge  Student (source)
2013-12-01 05:04:46 -0600 asked a question Creating a Virtual Gamelan App

Hey guys, my name is Kevin Phytagoras. I'm now working on final project for undergraduate thesis that using openCV. i'm creating a virtual gamelan app. its kinda like this http://www.soundstep.com/blog/experiments/jsdetection/

Gamelan is a music instrument originating from indonesia. it's kinda like xylophone. I'm trying to create an app that can simulate the real play of a gamelan using webcam as a motion detector.

Here is the rough drawing of what i want to create image description

the app workaround is like this

  1. user put down paper with picture of gamelan
  2. webcam capture the picture and designate the position of target area for gamelan mallet to be smashed
  3. webcam detect the motion of gamelan mallet
  4. the motion must past imaginary line for the motion to be considered as smashing
  5. smashed target area will make a sound according to which target area is smashed

I know that i must

  1. Detect the mallet movement
  2. Designate the area on paper
  3. Create the imaginary line
  4. Make the target area respond with sound when smashed

So what the best method to do that ? i like any suggestion that you can give.

i'm sorry if i ask too much, i just don't know how to start this project

thank you for all your attention. i'm waiting for any response.