Ask Your Question

el_cid's profile - activity

2017-06-23 05:15:28 -0500 asked a question How can I debug an cv::imencode error ?

I'm using a ZED Stereo Camera together with ROS on a Jetson TX1 (which uses a precompiled optimized OpenCV 2.4 ) I would like to use the compressed image transport functionality of ROS. But when I try to access such a compressed image, my programm fails. Debugging with comments reveiled, that the program crashes when calling this OpenCV function:

cv::imencode(".jpg", cv_ptr->image,, params)

at this location.

Running the program in debug mode shows the following error:

Thread 19 "zed_wrapper_nod" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7f87bac190 (LWP 4167)]
strlen () at ../sysdeps/aarch64/strlen.S:92
92  ../sysdeps/aarch64/strlen.S: No such file or directory.

Because on the Jetson I use precompiled OpenCV libraries, I first would like to refrain from starting to put debugging comments into OpenCV code. Can I maybe control the input arguments, if they are right? What would be typical faulty inputs?

(if you are interest to know more about the ROS side of this, see also my issue on github here )

2017-04-12 07:31:15 -0500 received badge  Enthusiast
2017-04-11 01:40:01 -0500 commented answer Why are the two images equal?

Thank you, matman. I had to think a little bit, but then I understood your answer. For other people having a similar issue I try to rephrase it: By using push_back() the matrix header is stored in the two vector elements. The matrix header is (beside other stuff, see link) a pointer to the matrix data. So in the end, the images-vector is just a vector of two pointers pointing to the same matrix, img1, which at the end of the second loop is the secondly taken picture.

2017-04-07 12:57:33 -0500 asked a question Why are the two images equal?

in my program, main calls a function which takes two pictures with a USB camera and writes them into a vector passed by reference to it. Due to an error I'm unable to find (for 2 days now...) the two images written into the vector are identical after I return to main (I test this with the function "equal(...)"), even if they should not be the same, as they were taken with a wait time in between, and I'm waving in front of the camera. Can some of you code angels spot an error I did? The equal() function is not the problem, I have tested it thoroughly.

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/videoio/videoio.hpp>

using namespace std;

//---------FUNCTION DECLARATIONS----------------
void       takePictures(vector<cv::Mat>&);
bool       equal(const cv::Mat&, const cv::Mat&);

int main(int argc, char* argv[])

  // Take pictures
  vector<cv::Mat> images;
  takePictures( images);

  bool sameImg = equal(images[0],images[1]);

  return 0;

//----------IMAGE TAKING FUNCTION---------------
void takePictures(vector<cv::Mat>& images)
  // open cameras
  cv::VideoCapture cap1(0);
  cv::Mat img1;

  // Picture taking procedure
  for ( int i = 1; i <= 2; i++ )
    cap1 >> img1;

bool equal(const cv::Mat & a, const cv::Mat & b)
    if ( (a.rows != b.rows) || (a.cols != b.cols) )
        return false;
    cv::Scalar s = sum( a - b );
    return (s[0]==0) && (s[1]==0) && (s[2]==0);

Thank you a lot in advance for your help.

2017-03-31 04:22:26 -0500 asked a question How is result of cornerSubPix() written into pointBuf?

In the camera calibration example (link , part 3. Find the pattern in the current input ), the presence of chessboard corners is checked detected with the function findChessboardCorners() (link to function doc) and latter detected with higher precision with cornerSubPix() (link to function doc).

What I don't understand is how the corner positions are written into pointBuf, as neither when passed to findChessboardCorners() nor when passed to the latter used function cornerSubPix() this vector of type vector < Point2f> is passed by reference.

Thank you in advance for your answer.

2017-03-30 03:13:18 -0500 marked best answer What means "Returns the specified element of the top-level mapping"?

In the camera calibration tutorial (link: http:// camera_calibration/camera_calibration.html# ), in part 1. Read the Settings) there is the line:

fs["Settings"] >> s;

which I don't understand. In the reference to the class FileStorage, of which fs is a member, [ ] is overloaded by:

FileNode    operator[] (const String &nodename) const

which is described by

Returns the specified element of the top-level mapping.

  1. What does this description mean?
  2. Why in the definition of the overloading, there is a "const" after "...&nodename)" ?
  3. What is the operator >> doing? By default it's the bitwhise shifting, right? What would bitwise shifting do here?

Thank you in advance for your answers.