Skip to content

Commit

Permalink
Merge pull request lagadic#1525 from fspindle/fix_build_rs2
Browse files Browse the repository at this point in the history
Fix build around realsense grabber usage
  • Loading branch information
fspindle authored Dec 18, 2024
2 parents b0ac244 + e23cb08 commit 3e3b020
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 28 deletions.
25 changes: 12 additions & 13 deletions modules/ar/src/panda3d-simulator/vpPanda3DPostProcessFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,18 @@
#include <lightRampAttrib.h>

BEGIN_VISP_NAMESPACE
const char *vpPanda3DPostProcessFilter::FILTER_VERTEX_SHADER = R"shader(
#version 330
in vec4 p3d_Vertex;
uniform mat4 p3d_ModelViewProjectionMatrix;
in vec2 p3d_MultiTexCoord0;
out vec2 texcoords;
void main()
{
gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex;
texcoords = p3d_MultiTexCoord0;
}
)shader";
const std::string vpPanda3DPostProcessFilter::FILTER_VERTEX_SHADER =
"#version 330\n"
"in vec4 p3d_Vertex;\n"
"uniform mat4 p3d_ModelViewProjectionMatrix;\n"
"in vec2 p3d_MultiTexCoord0;\n"
"out vec2 texcoords;\n"

"void main()\n"
"{\n"
" gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex;\n"
" texcoords = p3d_MultiTexCoord0;\n"
"}\n";

void vpPanda3DPostProcessFilter::setupScene()
{
Expand Down
2 changes: 1 addition & 1 deletion modules/vision/src/pose-estimation/vpPoseLagrange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ void vpPose::poseLagrangePlan(vpHomogeneousMatrix &cMo, bool *p_isPlan, double *
const unsigned int index_5 = 5;

// determination of the plane equation a X + b Y + c Z + d = 0
double a, b, c, d;
double a = 0, b = 0, c = 0, d = 0;

// Checking if coplanar has already been called and if the plan coefficients have been given
bool p_isplan_and_p_a_no_null = (p_isPlan != nullptr) && (p_a != nullptr);
Expand Down
7 changes: 6 additions & 1 deletion tutorial/computer-vision/tutorial-pose-from-points-live.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ int main(int argc, char **argv)
}

vpImage<unsigned char> I;
vpCameraParameters cam;

//! [Grabber]
#if defined(VISP_HAVE_V4L2)
Expand All @@ -92,21 +93,25 @@ int main(int argc, char **argv)
g.setDevice(device.str());
g.setScale(1);
g.open(I);
cam.initPersProjWithoutDistortion(840, 840, I.getWidth() / 2, I.getHeight() / 2); // Default parameters
#elif defined(VISP_HAVE_DC1394)
(void)opt_device; // To avoid non used warning
std::cout << "Use DC1394 grabber" << std::endl;
vp1394TwoGrabber g;
g.open(I);
cam.initPersProjWithoutDistortion(840, 840, I.getWidth() / 2, I.getHeight() / 2); // Default parameters
#elif defined(VISP_HAVE_CMU1394)
(void)opt_device; // To avoid non used warning
std::cout << "Use CMU1394 grabber" << std::endl;
vp1394CMUGrabber g;
g.open(I);
cam.initPersProjWithoutDistortion(840, 840, I.getWidth() / 2, I.getHeight() / 2); // Default parameters
#elif defined(VISP_HAVE_FLYCAPTURE)
(void)opt_device; // To avoid non used warning
std::cout << "Use FlyCapture grabber" << std::endl;
vpFlyCaptureGrabber g;
g.open(I);
cam.initPersProjWithoutDistortion(840, 840, I.getWidth() / 2, I.getHeight() / 2); // Default parameters
#elif defined(VISP_HAVE_REALSENSE2)
(void)opt_device; // To avoid non used warning
std::cout << "Use Realsense 2 grabber" << std::endl;
Expand All @@ -130,11 +135,11 @@ int main(int argc, char **argv)
cv::Mat frame;
g >> frame; // get a new frame from camera
vpImageConvert::convert(frame, I);
cam.initPersProjWithoutDistortion(840, 840, I.getWidth() / 2, I.getHeight() / 2); // Default parameters
#endif
//! [Grabber]

// Parameters of our camera
vpCameraParameters cam(840, 840, I.getWidth() / 2, I.getHeight() / 2); // Default parameters
vpXmlParserCamera parser;
if (!opt_intrinsic_file.empty() && !opt_camera_name.empty()) {
std::cout << "Intrinsic file: " << opt_intrinsic_file << std::endl;
Expand Down
7 changes: 2 additions & 5 deletions tutorial/tracking/blob/tutorial-blob-tracker-live.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ int main()
vpImage<unsigned char> I; // Create a gray level image container
int opt_device = 0; // For OpenCV and V4l2 grabber to set the camera device

//! [Grabber]
//! [Grabber]
#if defined(VISP_HAVE_V4L2)
vpV4l2Grabber g;
std::ostringstream device;
Expand Down Expand Up @@ -80,9 +80,6 @@ int main()
config.enable_stream(RS2_STREAM_COLOR, 640, 480, RS2_FORMAT_RGBA8, 30);
g.open(config);
g.acquire(I);

std::cout << "Read camera parameters from Realsense device" << std::endl;
cam = g.getCameraParameters(RS2_STREAM_COLOR, vpCameraParameters::perspectiveProjWithoutDistortion);
#elif ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI))|| ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_VIDEOIO))
cv::VideoCapture g(opt_device); // open the default camera
if (!g.isOpened()) { // check if we succeeded
Expand Down Expand Up @@ -116,7 +113,7 @@ int main()
bool germ_selected = false;
vpMouseButton::vpMouseButtonType button;

while (! quit) {
while (!quit) {
try {
#if defined(VISP_HAVE_V4L2) || defined(VISP_HAVE_DC1394) || defined(VISP_HAVE_CMU1394) || defined(VISP_HAVE_FLYCAPTURE) || defined(VISP_HAVE_REALSENSE2)
g.acquire(I);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ int main()
config.enable_stream(RS2_STREAM_COLOR, 640, 480, RS2_FORMAT_RGBA8, 30);
g.open(config);
g.acquire(I);

std::cout << "Read camera parameters from Realsense device" << std::endl;
cam = g.getCameraParameters(RS2_STREAM_COLOR, vpCameraParameters::perspectiveProjWithoutDistortion);
#elif ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI))|| ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_VIDEOIO))
std::cout << "Use OpenCV grabber on device " << opt_device << std::endl;
cv::VideoCapture g(opt_device); // Open the default camera
Expand Down Expand Up @@ -129,7 +126,7 @@ int main()
//! [me ellipse container]

bool quit = false;
while (! quit) {
while (!quit) {
#if defined(VISP_HAVE_V4L2) || defined(VISP_HAVE_DC1394) || defined(VISP_HAVE_CMU1394) || defined(VISP_HAVE_FLYCAPTURE) || defined(VISP_HAVE_REALSENSE2)
g.acquire(I);
#elif ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI))|| ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_VIDEOIO))
Expand Down
5 changes: 1 addition & 4 deletions tutorial/tracking/moving-edges/tutorial-me-line-tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ int main()
config.enable_stream(RS2_STREAM_COLOR, 640, 480, RS2_FORMAT_RGBA8, 30);
g.open(config);
g.acquire(I);

std::cout << "Read camera parameters from Realsense device" << std::endl;
cam = g.getCameraParameters(RS2_STREAM_COLOR, vpCameraParameters::perspectiveProjWithoutDistortion);
#elif ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI))|| ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_VIDEOIO))
std::cout << "Use OpenCV grabber on device " << opt_device << std::endl;
cv::VideoCapture g(opt_device); // Open the default camera
Expand Down Expand Up @@ -146,7 +143,7 @@ int main()

//! [loop]
bool quit = false;
while (! quit) {
while (!quit) {
#if defined(VISP_HAVE_V4L2) || defined(VISP_HAVE_DC1394) || defined(VISP_HAVE_CMU1394) || defined(VISP_HAVE_FLYCAPTURE) || defined(VISP_HAVE_REALSENSE2)
g.acquire(I);
#elif ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI))|| ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_VIDEOIO))
Expand Down

0 comments on commit 3e3b020

Please sign in to comment.