Ask Your Question

pawkolodziej's profile - activity

2016-10-27 09:46:15 -0600 received badge  Enthusiast
2016-10-24 11:45:46 -0600 commented question Color Filtering with use inRange function

Ok i uderstand my problem. I used HSV. Thx. But what do you mean about opencv's c-api? i used a wrong function?

2016-10-23 10:13:34 -0600 commented question Color Filtering with use inRange function

I edit my post. So, I take a image from camera, and I want to see for example only red color.

2016-10-23 04:48:31 -0600 received badge  Editor (source)
2016-10-23 04:45:28 -0600 asked a question Color Filtering with use inRange function

Hi everyone,

I make a simply code to filter colors:

if (c == 52)
    {

        char c = cvWaitKey(33);


        {

            cout << left << "Ustawienia algorytmow przetwarzania obrazu...";
            cout << "\nWcisnij klawisz 4 zeby wrocic do poprzedniego ekranu.";
            cout << "\n\nOpis algorytmow:\nTresholding - jest to jedna z podstawowych operacji morfologicznych. Mozliwe metody:";
            cout << "\n\nUstawienie wartosci zero spowoduje wylaczenie algorytmu.";
            imshow("Algorytmy", wzor);

            cvNamedWindow("Algorytmy");
            while (1)
            {
                klatka = cvQueryFrame(capture);
                IplImage* tmp = cvCloneImage(klatka);

                //cvNamedWindow("Ustawienia");
                cvNamedWindow("Ustawienia", CV_WINDOW_AUTOSIZE);
                createTrackbar("Algorytm:", "Ustawienia", &tempmatching_typ, 4, 0);
                createTrackbar("Thresholding", "Ustawienia", &algorytm_erozja, 255, 0);
                createTrackbar("Metoda:", "Ustawienia", &erozja_typ, 4, 0);

                createTrackbar("R>", "Ustawienia", &Filtr_RL, 255, 0);
                createTrackbar("<R", "Ustawienia", &Filtr_RP, 255, 0);
                createTrackbar("G>", "Ustawienia", &Filtr_GL, 255, 0);
                createTrackbar("<G", "Ustawienia", &Filtr_GP, 255, 0);
                createTrackbar("B>", "Ustawienia", &Filtr_BL, 255, 0);
                createTrackbar("<B", "Ustawienia", &Filtr_BP, 255, 0);


                cvResizeWindow("Ustawienia", 300, 200);


                if (algorytm_erozja > 1)
                {
                    cvtColor(klatka, src_gray, CV_BGR2GRAY);
                    threshold(src_gray, src, algorytm_erozja, 255, erozja_typ);
                }
                else
                {

                    inRange(klatka, Scalar(Filtr_BL,Filtr_GL,Filtr_RL), Scalar(Filtr_BP, Filtr_GP, Filtr_RP), src);

                };

                imshow("Algorytmy", src);

                if (cvWaitKey(15) == 52) break;
                cvReleaseImage(&tmp);
            }

            cvDestroyWindow("Algorytmy");
            cvDestroyWindow("Ustawienia");
            MenuGlowne(0);
        }
    };

The problem is that, it does not work as I want. For exampe, when i set range of Red to 200-255, but Blue , and Green to 0. Then i see nothing, but i have a red square on picture.

Does anyone have any idea what I'm doing wrong?

Screens from my program: screen1 screen2

Thx for help

2016-10-20 08:44:04 -0600 received badge  Self-Learner (source)
2016-10-20 08:03:31 -0600 commented question minMaxLoc, maxVal always is 1

ok, now i understand. I removed normalize(). Thx for explain.

2016-10-20 07:59:03 -0600 commented question minMaxLoc, maxVal always is 1

I want to see the result from funkction minMaxLoc, in range 0.0 - 1.0 where 1.0 is the best score.

2016-10-20 07:55:06 -0600 commented question minMaxLoc, maxVal always is 1

I thnk so. Normalize the values in array to defined range?

2016-10-20 06:03:29 -0600 commented question minMaxLoc, maxVal always is 1
2016-10-20 05:54:34 -0600 asked a question minMaxLoc, maxVal always is 1

Hi everyone

When i use minMaxLoc, to find the best score of matchtemplating, in maxVal i have always value 1.

My code:

void MatchingMethod(int, void*)

{

Mat img_display;
img.copyTo(img_display);
int result_cols = img.cols - templ.cols + 1;
int result_rows = img.rows - templ.rows + 1;
result.create(result_rows, result_cols, CV_32F);
matchTemplate(img_display, templ, result, CV_TM_SQDIFF);
normalize(result, result, 0, 1, NORM_MINMAX, -1, Mat());
/// Localizing the best match with minMaxLoc
double minVal; double maxVal; Point minLoc; Point maxLoc;Point matchLoc;
minMaxLoc(result, &minVal, &maxVal, &minLoc, &maxLoc, Mat());
scores = maxVal;

if (scores > 0.0)
{
    printf("\nWynik:%\F", minVal);
    printf("  %\F", maxVal);
    printf(" %\F", minLoc);
    printf(" %\F", maxLoc);
};

if someone can help me?