Ask Your Question

quina's profile - activity

2019-11-11 01:27:42 -0600 received badge  Notable Question (source)
2019-01-28 15:20:13 -0600 received badge  Popular Question (source)
2018-03-23 11:01:18 -0600 commented answer Showing a rectangle on the courser and cutting out

Thank you so much, updating the image did it!

2018-03-23 11:00:37 -0600 received badge  Supporter (source)
2018-03-23 11:00:36 -0600 marked best answer Showing a rectangle on the courser and cutting out

Hi there,

I am pretty new to programming and especially to C++. I want to write a program that does the following:

  1. Scans a specified folder for images; the first one is opened and displayed.
  2. The user has a rectangle of specified size over the courser and can "place" this rectangle anywhere he wants on that image by clicking. He can place as many rectangles as he wishes.
  3. If all the rectangles are placed, pressing a button (e.g. space) cuts all the parts of the image that are within those rectangles and saves them seperately in a specified folder (so that we have x image files for the respective x rectangles). The next image is loaded and we go back to step 2.

As you can see in the code below, my program currently shows one image that is passed in the command line and logs the position of mouse clicks inside the image window (becuase I will need the mouse position).

I am currently trying to draw a rectangle around the courser that moves with it, however, all the documenatries I read use the rectangle()-function, which I cannot find. I only have the cvRectangle()-function, and this one does not accept my image of type Mat. I found in a post on Stack Overflow that said I need to convert it to IplImage, but it does not like that either. Here (http://answers.opencv.org/question/62...) it says that the function has been removed and that i have to use Imgproc.rectangle(), but my program does not know Imgproc() (already tried to include the headerfile with that name and imgcodecs).

Another question would be how to make the rectangle move with the coursor and placing it not until the button is clicked. Since I am rather new to programming, I am not sure where the code for this would go. If I place it inside my CallBackFunc(), it does not know img. If I place it inside my main(), it cannot access x, y, ... I will probably have to pass img to the CallBackFunc, but everything in proper time. :)

I won't be able to check here every day, so I'll probably be unable to reply until monday. Thanks a lot for answers, though, it's much appreciated! Have a good weekend!

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

using namespace cv;
using namespace std;


void CallBackFunc(int event, int x, int y, int flags, void* userdata)
{
    if (event == EVENT_LBUTTONDOWN)
    {
        cout << "Left button of the mouse is clicked - position (" << x << ", " << y << ")" << endl;
    }
    else if (event == EVENT_RBUTTONDOWN)
    {
        cout << "Right button of the mouse is clicked - position (" << x << ", " << y << ")" << endl;
    }
    else if (event == EVENT_MBUTTONDOWN)
    {
        cout << "Middle button of the mouse is clicked - position (" << x << ", " << y << ")" << endl;
    }
    //else if (event == EVENT_MOUSEMOVE)
    //{
    //  cout << "Mouse move over the window - position (" << x << ...
(more)
2018-03-23 11:00:36 -0600 received badge  Scholar (source)
2018-03-23 10:54:02 -0600 commented answer Showing a rectangle on the courser and cutting out

I suppose it has to do with the function pointer of the callback function? Because when doing it like this, VS tells me

2018-03-23 10:47:40 -0600 commented answer Showing a rectangle on the courser and cutting out

Thanks so much for your continued assistance! As mentioned above, rectangle now works when used in main(). However, whe

2018-03-23 10:42:25 -0600 commented question Showing a rectangle on the courser and cutting out

Wow, this is weird. I could have sworn Visual Studio did not find rectangle() before - now I can use it without a proble

2018-03-23 07:50:38 -0600 asked a question Showing a rectangle on the courser and cutting out

Showing a rectangle on the courser and cutting out Hi there, I am pretty new to programming and especially to C++. I w

2018-03-22 07:01:49 -0600 commented question Getting the OpenCV library to work with C++

works now, thanks!

2018-03-19 08:50:39 -0600 commented question Getting the OpenCV library to work with C++

so these "errors" seem to be irrelevant, is this correct? when executing the program w/o debugging, it shows Usage: disp

2018-03-19 08:47:20 -0600 commented question Getting the OpenCV library to work with C++

the error-windows about missing the missing dll disappeared - thank you! why do i need to use the dll in the bin directo

2018-03-19 08:36:02 -0600 commented question Getting the OpenCV library to work with C++

the error-windows about missing the missing dll disappeared - thank you! why do i need to use the dll in the bin directo

2018-03-19 07:19:21 -0600 commented question Getting the OpenCV library to work with C++

i tried a system reboot in the meantime, still does not work. path gives me: PATH=[...........];C:\opencv\build\x64\vc

2018-03-19 06:49:29 -0600 commented question Getting the OpenCV library to work with C++

hi, i already tried to add it to my env variables (since cmake threw the same error, i'm already a little used to that)

2018-03-19 06:40:07 -0600 commented question Getting the OpenCV library to work with C++

hi berak, thanks a lot for you continued support. sorry i couldn't answser earlier, i was out of town over the weekend

2018-03-19 06:32:48 -0600 commented question Getting the OpenCV library to work with C++

hi berak, thanks a lot for you continued support. sorry i couldn't answser earlier, i was out of town over the weekend

2018-03-16 09:32:30 -0600 commented question Getting the OpenCV library to work with C++

I thought that's what I did: https://pasteboard.co/HcaV15x.png For some reason though, I get another error now: it simp

2018-03-16 09:13:00 -0600 edited question Getting the OpenCV library to work with C++

Getting the OpenCV library to work with C++ Hello everyone, just a short heads-up: I have never used OpenCV and barely

2018-03-16 08:52:39 -0600 commented question Getting the OpenCV library to work with C++

After setting this to x64, I get the error 1>------ Erstellen gestartet: Projekt: OpenCV_Test_Console, Konfiguratio

2018-03-16 08:51:50 -0600 commented question Getting the OpenCV library to work with C++

After setting this to x64, I get the error 1>------ Erstellen gestartet: Projekt: OpenCV_Test_Console, Konfiguratio

2018-03-16 08:45:19 -0600 commented question Getting the OpenCV library to work with C++

I just posted it because I thought that maybe there is an easy way to get it to work in Code Blocks and that I'm just to

2018-03-16 08:37:28 -0600 received badge  Editor (source)
2018-03-16 08:37:28 -0600 edited question Getting the OpenCV library to work with C++

Getting the OpenCV library to work with C++ Hello everyone, just a short heads-up: I have never used OpenCV and barely

2018-03-16 08:13:55 -0600 asked a question Getting the OpenCV library to work with C++

Getting the OpenCV library to work with C++ Hello everyone, just a short heads-up: I have never used OpenCV and barely