Ask Your Question

Berkay's profile - activity

2017-10-04 11:15:30 -0500 commented answer comparing two image

using namespace cv; using namespace std; int main(){ Mat img1,img2,dst; VideoCapture capture(0); // kamera aç name

2017-10-04 11:12:23 -0500 commented answer comparing two image

using namespace cv; using namespace std; int main(){ Mat img1,img2,dst; VideoCapture capture(0); // kamera aç namedWin

2017-10-03 16:23:28 -0500 commented answer comparing two image

this code can be builded but when ı work it, a fatal error happens

2017-10-03 14:40:53 -0500 edited question comparing two image

comparing two image Hi, ı want to compare two images and if there is any difference ı want to get 1 or 0 in C++ language

2017-10-03 14:40:07 -0500 edited question comparing two image

comparing two image Hi, ı want to compare two images and if there is any difference ı want to get 1 or 0 in C++ language

2017-10-03 14:38:25 -0500 asked a question comparing two image

comparing two image hi, ı want to compare two images and if there is any difference ı want to get 1 or 0 in C++ language

2015-12-01 11:09:07 -0500 commented answer counting vehicle number with cascade

thanks for respond, ı added this two line num_of_vehicle+=cars.size(); cout << "Found " <<num_of_vehicle&lt;&lt; "="" cars"="" &lt;<endl;<="" strong=""> and ı make number of car counted but this line does not give true vehicle number because cascade can perceive the same car several times until that car vanish on the screen

2015-12-01 11:08:39 -0500 received badge  Student (source)
2015-12-01 05:42:33 -0500 asked a question counting vehicle number with cascade

hi, I wrote this codes to detect vehicles inside each frame in the video. Now I want to count them but I don't know how to do it. Could you show me how, please?

#include "stdafx.h"
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include <vector>

using namespace cv;
using namespace std;

int main(){

    VideoCapture cap("arabalar2.avi"); // open the video file for reading

    if ( !cap.isOpened() )  // if not success, exit program
    {
         cout << "Cannot open the video file" << endl;
         return -1;
    }

    Mat gray;

    string cascade_file= "C:/Cascades/haarcascades/cars.xml";
    CascadeClassifier cascade;

    if (cascade_file.empty() || !cascade.load(cascade_file))
    {
        cout << "Hata: cascade dosyası bulunamadı!n";
        return -1;
    }

    namedWindow("MyVideo",CV_WINDOW_NORMAL);  

    while(1){

        Mat frame;

        bool bSuccess = cap.read(frame); // read a new frame from video

         if (!bSuccess) //if not success, break loop
         {
              cout << "Cannot read the frame from video file" << endl;
              break;
         }

        cvtColor(frame, gray, CV_BGR2GRAY);
        equalizeHist(gray, gray);
        vector<Rect> cars;

        cascade.detectMultiScale(gray, cars, 1.1, 3, CV_HAAR_DO_CANNY_PRUNING|CV_HAAR_SCALE_IMAGE, Size(30,30));

        for (int i = 0; i < cars.size(); i++) // draw a rectangle for dedected vehicles
        {
            Rect rect = cars[i];
            rectangle(frame, rect, CV_RGB(0,255,0), 1);
        }

        imshow("MyVideo", frame);

        if(waitKey(30) == 27) //wait for 'esc' key press for 30 ms. If 'esc' key is pressed, break loop
        {
                cout << "esc key is pressed by user" << endl; 
                break; 
        }

    }
    return 0;
}
2015-10-15 12:57:27 -0500 asked a question Kalman filter compile error

ı found a kalman tutorial from http://opencvexamples.blogspot.com/20... when ı build this codes, VS 2012 gives me error C2100: illegal indirection about line which includes KF.transitionMatrix = *(Mat_<float>(4, 4) << 1,0,1,0, 0,1,0,1, 0,0,1,0, 0,0,0,1); what can ı do to vanish this error?

2015-10-15 12:51:39 -0500 received badge  Supporter (source)
2015-10-15 12:47:56 -0500 received badge  Scholar (source)
2015-10-12 04:48:00 -0500 commented answer drawing square on image

thank you...

2015-10-12 03:36:45 -0500 asked a question drawing square on image
#include "stdafx.h"
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>

using namespace std;
using namespace cv;

volatile int knt=0;

Mat img_save;

void CallBackFunc(int event, int x, int y, int flags, void* userdata){

    if(event == EVENT_LBUTTONDOWN){

        Mat dst;

        if(knt==0){
           dst=imread("Nature.jpg");
           knt=1;
        }

        else if(knt==1)
            dst=img_save.clone();

        img_save=dst;

        int data=50;
        Rect dikdortgen( (x-data/2), (y-data/2), data, data );
        rectangle(dst, dikdortgen, CV_RGB(255,255,255),2);

        imshow("My Window", dst);
     }
}


int main(int argc, char** argv){

     int kontrol=0;
     Mat img = imread("Nature.JPG"); // Read image from file 

     if ( img.empty() )  //if fail to read the image
     { 
          cout << "Error loading the image" << endl;
          return -1; 
     }

     namedWindow("My Window", CV_WINDOW_NORMAL); //Create a window

     setMouseCallback("My Window", CallBackFunc, 0); //set the callback function 

     if(kontrol==0){
        imshow("My Window", img); //show the image
        kontrol=1;
     }

     waitKey(0); // Wait until user press some key   
     return 0;
}

when ı run this program ı can draw a square where ı click on the image, but there is problem, ı don't have to see previous drawing square when ı click anywhere else could you help?

2015-10-10 08:58:22 -0500 commented answer how to use Mat img on all function without any calling function

this does not solve my problem because actually ı had to indicate that any function instead of any loop. it's my mistake... ı want to use that image all functions which are out of main()

2015-10-10 05:26:22 -0500 commented question how to use Mat img on all function without any calling function

ı meant that if you state volatile variable in C, you can use it on any loop as variable. it's not necassary to introduce one more times in loop which uses volatile variable. ı want to do like this for an image that ı loaded

2015-10-10 05:13:41 -0500 received badge  Editor (source)
2015-10-10 05:12:53 -0500 asked a question how to use Mat img on all function without any calling function

ı want to use Mat img=imread("Nature.jpg"); to all func. such volatile int temp; is there any way for this?

2015-10-10 04:59:39 -0500 commented question entered numbers are overlapping

thank you...

2015-10-10 04:17:48 -0500 asked a question entered numbers are overlapping
  why does numbers of image titles overlap each other?

          #include "stdafx.h"
>         #include <opencv2/highgui/highgui.hpp>
>         #include <opencv2/opencv.hpp>
>         #include <iostream>
>         #include <string>
>         
>         using namespace std;
>         using namespace cv;
>         
>         string print_name(int x){
>         
>           char buffer[15];
>           sprintf_s(buffer,"Resim %d",x);
>           return buffer;
>         }
>         
>         int main( int argc, char** argv ){
>             
>           int k=0;
>         
>             Mat small_image = imread("pluto.jpg"); 
>         
>             Mat im_out = Mat::zeros(600, 800, CV_8UC3);
>         
>             for (int i=0; i < 4; i++){
>         
>                 for(int j=0; j < 3; j++){
>                   k++;
>                   putText(small_image, print_name(k), Point(45, 180),
>                          FONT_HERSHEY_SCRIPT_SIMPLEX, 1,
>                          Scalar::all(255), 1,CV_AA);
>                   small_image.copyTo(im_out(Rect(i*200,j*200,small_image.cols,
>                          small_image.rows)));
>                 }
>             }
>             
>             imshow("window", im_out);
>             waitKey(0);
>             return 0;
>         }
2015-10-10 02:49:49 -0500 received badge  Enthusiast
2015-09-30 05:21:50 -0500 asked a question drawing contour to any object of image

hi, my purpose is to draw a contour to surrounding the object which has a wanted color, I can detect any color from image and I know how to draw contour to surrounding of all objects in image , but for instance I don't know how I'm able to draw contour for only red object on the image with the program below...

image description

#include "stdafx.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>

using namespace std;
using namespace cv;

Mat redFilter(const Mat& src){

    Mat redOnly;

    cvtColor(src,redOnly,CV_BGR2HSV);
    inRange(src, Scalar(0, 0, 0), Scalar(0, 0, 255), redOnly);

    return redOnly;
}

int main(int argc, char** argv){

    Mat input = imread("sekiller2.png");
    imshow("input", input);

    Mat redOnly = redFilter(input);
    imshow("redOnly", redOnly);

    waitKey();
    return 0;
}
2015-09-26 05:29:23 -0500 asked a question cvtColor BGR to HSV

Hi, below program does not work, ı can build without error but when ı click "start without debug" it gives error which is about cvtColor(); what should ı do? how can ı convert ranged image to HSV form?

#include "stdafx.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>

using namespace std;
using namespace cv;

Mat redFilter(const Mat& src){

    Mat redOnly;

    cvtColor(src,redOnly,CV_BGR2HSV);
    inRange(src, Scalar(0, 0, 0), Scalar(0, 0, 255), redOnly);

    return redOnly;
}

int main(int argc, char** argv){

    Mat img_thrsld, img_trans, input = imread("sekiller2.png");
    imshow("input", input);

    Mat redOnly = redFilter(input);

    cvtColor(redOnly, img_trans, CV_BGR2GRAY);

    waitKey();
    return 0;
}