Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

hi Nate, simple answer, - you have to set the roi before calling cvShowImage.

besides that , 2 remarks:

  • next time, please add the actual code, not a screenshot of it (will make it easier for others to try/modify it)

  • if you're just starting with opencv (and thus don't have a ton a of legacy code to support), please avoid the old c-api, support for that is fading quickly, please move over to c++ asap.


so, the more modern version of your code would be like this:

#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
using namespace cv;

int main() 
{
    namedWindow("Example1");
    Mat img = imread("a:/very/long/path/to/o1.jpg");
    Mat roi = img( Rect(150,50,150,250) );
    imshow("Example1",roi);
    waitKey(0);
    return 0; // yea, c++, no cleanup nessecary!
}

hi Nate, simple answer, - you have to set the roi before calling cvShowImage.

besides that , 2 remarks:

  • next time, please add the actual code, not a screenshot of it (will make it easier for others to try/modify it)

  • if you're just starting with opencv (and thus don't have a ton a of legacy code to support), please avoid the old c-api, support for that is fading quickly, please move over to c++ asap.


so, the more modern version of your code would be like this:

#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
using namespace cv;

int main() 
{
    namedWindow("Example1");
    Mat img = imread("a:/very/long/path/to/o1.jpg");
    Mat roi = img( Rect(150,50,150,250) );
    imshow("Example1",roi);
    waitKey(0);
    return 0; // yea, c++, no cleanup nessecary!
}

hi Nate, simple answer, - you have to set the roi before calling cvShowImage.

besides that , 2 remarks:

  • next time, please add the actual code, not a screenshot (will make it easier for others to try/modify it)

  • if you're just starting with opencv (and thus don't have a ton a of legacy code to support), please avoid the old c-api, support for that is fading quickly, please move over to c++ asap.


so, the more modern version of your code would be like this:

#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
using namespace cv;

int main() 
{
    namedWindow("Example1");
    Mat img = imread("a:/very/long/path/to/o1.jpg");
    Mat roi = img( Rect(150,50,150,250) );
    imshow("Example1",roi);
    waitKey(0);
    return 0; // yea, c++, no cleanup nessecary!
}

".But Im not give up !!!" - ;) yea.

hi Nate, simple answer, - you have to set the roi before calling cvShowImage.

besides that , 2 remarks:

  • next time, please add the actual code, not a screenshot (will make it easier for others to try/modify it)

  • if you're just starting with opencv (and thus don't have a ton a of legacy code to support), please avoid the old c-api, support for that is fading quickly, please move over to c++ asap.


so, the more modern version of your code would be like this:

#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
using namespace cv;

int main() 
{
    namedWindow("Example1");
    Mat img = imread("a:/very/long/path/to/o1.jpg");
    if ( img.empty() ) { /* bark!!*/ }
    Mat roi = img( Rect(150,50,150,250) );
    imshow("Example1",roi);
    waitKey(0);
    return 0; // yea, c++, no cleanup nessecary!
}

".But Im not give up !!!" - ;) yea.