Skip to content

Commit

Permalink
Merge pull request #2 from lagadic/feat_opencv_modules
Browse files Browse the repository at this point in the history
Introduce opencv modules defines and remove deprecated samples
  • Loading branch information
fspindle authored Oct 26, 2023
2 parents b1ee149 + c740700 commit 1ea95ea
Show file tree
Hide file tree
Showing 31 changed files with 151 additions and 245 deletions.
2 changes: 1 addition & 1 deletion core/sample-vpColor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ int main()
d = new vpDisplayGDI;
#elif defined(VISP_HAVE_D3D9)
d = new vpDisplayD3D;
#elif defined(VISP_HAVE_OPENCV)
#elif defined(HAVE_OPENCV_HIGHGUI)
d = new vpDisplayOpenCV;
#endif

Expand Down
25 changes: 0 additions & 25 deletions core/sample-vpImageConvert-3.cpp

This file was deleted.

24 changes: 0 additions & 24 deletions core/sample-vpImageConvert-4.cpp

This file was deleted.

8 changes: 4 additions & 4 deletions core/sample-vpImageConvert-6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

int main()
{
#if defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)
vpImage<unsigned char> Ig; // A greyscale image
#if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_IMGCODECS)
vpImage<unsigned char> Ig; // A grayscale image
cv::Mat Ip;

// Read an image on a disk
vpImageIo::readPGM(Ig, "image.pgm");
// Convert the vpImage<unsigned char> in to greyscale cv::Mat
// Convert the vpImage<unsigned char> in to grayscale cv::Mat
vpImageConvert::convert(Ig, Ip);
// Treatments on cv::MatIp
// Treatments on cv::Mat Ip
//...
// Save the cv::Mat on the disk
cv::imwrite("image.pgm", Ip);
Expand Down
22 changes: 0 additions & 22 deletions core/sample-vpImageConvert-7.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion core/sample-vpImageConvert-8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

int main()
{
#if defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)
#if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_IMGCODECS)
vpImage<unsigned char> Ig; // A grayscale image
cv::Mat Ip;

Expand Down
2 changes: 1 addition & 1 deletion core/sample-vpImageConvert-9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

int main()
{
#if defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)
#if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_IMGCODECS)
vpImage<vpRGBa> Ic; // A color image
cv::Mat Ip;

Expand Down
21 changes: 0 additions & 21 deletions core/sample-vpImageConvert.cpp

This file was deleted.

6 changes: 3 additions & 3 deletions core/sample-vpImageFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

int main()
{
#if (VISP_HAVE_OPENCV_VERSION >= 0x020100) && (VISP_HAVE_OPENCV_VERSION < 0x030000) // Cany uses OpenCV >=2.1.0 and < 3.0.0
#if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC)
// Constants for the Canny operator.
const unsigned int gaussianFilterSize = 5;
const double thresholdCanny = 15;
Expand All @@ -13,9 +13,9 @@ int main()
vpImage<unsigned char> Isrc;
vpImage<unsigned char> Icanny;

//First grab the source image Isrc.
// First grab the source image Isrc.

//Apply the Canny edge operator and set the Icanny image.
// Apply the Canny edge operator and set the Icanny image.
vpImageFilter::canny(Isrc, Icanny, gaussianFilterSize, thresholdCanny, apertureSobel);
#endif
return (0);
Expand Down
6 changes: 3 additions & 3 deletions detection/sample-vpDetectorFace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

int main()
{
#if (VISP_HAVE_OPENCV_VERSION >= 0x020200)
#if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_OBJDETECT)
vpImage<unsigned char> I;
vpDetectorFace face_detector;
face_detector.setCascadeClassifierFile("haarcascade_frontalface_alt.xml");

while(1) {
// acquire a new image in I
while (1) {
// Acquire a new image in I
bool face_found = face_detector.detect(I);
if (face_found) {
vpRect face_bbox = face_detector.getBBox(0); // largest face has index 0
Expand Down
6 changes: 3 additions & 3 deletions gui/sample-vpDisplay-2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ int main()
d = new vpDisplayGDI;
#elif defined(VISP_HAVE_D3D9)
d = new vpDisplayD3D;
#elif defined(VISP_HAVE_OPENCV)
#elif defined(HAVE_OPENCV_HIGHGUI)
d = new vpDisplayOpenCV;
#endif

Expand All @@ -43,11 +43,11 @@ int main()
vpDisplay::flush(I);

// Updates the color image with the original loaded image and the overlay
vpDisplay::getImage(I, Ioverlay) ;
vpDisplay::getImage(I, Ioverlay);

// Write the color image on the disk
std::string ofilename("overlay.ppm");
vpImageIo::writePPM(Ioverlay, ofilename) ;
vpImageIo::writePPM(Ioverlay, ofilename);

// Wait for a click in the display window
vpDisplay::getClick(I);
Expand Down
6 changes: 3 additions & 3 deletions gui/sample-vpDisplay-3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ int main()
d = new vpDisplayGDI;
#elif defined(VISP_HAVE_D3D9)
d = new vpDisplayD3D;
#elif defined(VISP_HAVE_OPENCV)
#elif defined(HAVE_OPENCV_HIGHGUI)
d = new vpDisplayOpenCV;
#endif

Expand All @@ -42,11 +42,11 @@ int main()
vpDisplay::flush(I);

// Updates the color image with the original loaded image and the overlay
vpDisplay::getImage(I, Ioverlay) ;
vpDisplay::getImage(I, Ioverlay);

// Write the color image on the disk
std::string ofilename("overlay.ppm");
vpImageIo::writePPM(Ioverlay, ofilename) ;
vpImageIo::writePPM(Ioverlay, ofilename);

// Wait for a click in the display window
vpDisplay::getClick(I);
Expand Down
6 changes: 3 additions & 3 deletions gui/sample-vpDisplay-4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ int main()
d = new vpDisplayGDI;
#elif defined(VISP_HAVE_D3D9)
d = new vpDisplayD3D;
#elif defined(VISP_HAVE_OPENCV)
#elif defined(HAVE_OPENCV_HIGHGUI)
d = new vpDisplayOpenCV;
#else
std::cout << "Sorry, no video device is available" << std::endl;
Expand Down Expand Up @@ -52,11 +52,11 @@ int main()
event = vpDisplay::getKeyboardEvent(I, &key[0], false);
if (event) {
std::cout << "Key detected: " << key << std::endl;
cpt_event ++;
cpt_event++;
}

vpTime::wait(5); // wait 5 ms
} while(cpt_event < 5);
} while (cpt_event < 5);

#ifdef VISP_HAVE_DISPLAY
delete d;
Expand Down
6 changes: 3 additions & 3 deletions gui/sample-vpDisplay-5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int main()
d = new vpDisplayGDI;
#elif defined(VISP_HAVE_D3D9)
d = new vpDisplayD3D;
#elif defined(VISP_HAVE_OPENCV)
#elif defined(HAVE_OPENCV_HIGHGUI)
d = new vpDisplayOpenCV;
#else
std::cout << "Sorry, no video device is available" << std::endl;
Expand Down Expand Up @@ -50,11 +50,11 @@ int main()
event = vpDisplay::getKeyboardEvent(I, &key[0], false);
if (event) {
std::cout << "Key detected: " << key << std::endl;
cpt_event ++;
cpt_event++;
}

vpTime::wait(5); // wait 5 ms
} while(cpt_event < 5);
} while (cpt_event < 5);

#ifdef VISP_HAVE_DISPLAY
delete d;
Expand Down
6 changes: 3 additions & 3 deletions gui/sample-vpDisplay-6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int main()
d = new vpDisplayGDI;
#elif defined(VISP_HAVE_D3D9)
d = new vpDisplayD3D;
#elif defined(VISP_HAVE_OPENCV)
#elif defined(HAVE_OPENCV_HIGHGUI)
d = new vpDisplayOpenCV;
#else
std::cout << "Sorry, no video device is available" << std::endl;
Expand Down Expand Up @@ -50,11 +50,11 @@ int main()
event = vpDisplay::getKeyboardEvent(I, &key[0], false);
if (event) {
std::cout << "Key detected: " << key << std::endl;
cpt_event ++;
cpt_event++;
}

vpTime::wait(5); // wait 5 ms
} while(cpt_event < 5);
} while (cpt_event < 5);

#ifdef VISP_HAVE_DISPLAY
delete d;
Expand Down
2 changes: 1 addition & 1 deletion gui/sample-vpDisplay-7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ int main()
d = new vpDisplayGDI;
#elif defined(VISP_HAVE_D3D9)
d = new vpDisplayD3D;
#elif defined(VISP_HAVE_OPENCV)
#elif defined(HAVE_OPENCV_HIGHGUI)
d = new vpDisplayOpenCV;
#else
std::cout << "Sorry, no video device is available" << std::endl;
Expand Down
Loading

0 comments on commit 1ea95ea

Please sign in to comment.