Ask Your Question

akihiko's profile - activity

2020-04-18 16:30:49 -0600 received badge  Notable Question (source)
2020-01-26 05:03:48 -0600 received badge  Notable Question (source)
2019-06-21 03:10:32 -0600 received badge  Popular Question (source)
2018-08-22 00:13:37 -0600 received badge  Popular Question (source)
2018-05-07 14:19:50 -0600 received badge  Teacher (source)
2017-08-09 04:08:17 -0600 answered a question cv::VideoCapture::open(file) causes fatal memory error

I've solved this issue.

By analyzing the program with ldd, I found that it was linked to, for example, /usr/lib/libopencv_highgui.so. However, in x86_64 system, it should be /usr/lib/x86_64-linux-gnu/libopencv_highgui.so. In my system, both files were installed.

The issue was caused by /usr/lib/libopencv_*.so (I'm not sure how I installed them. Maybe from source code...?). I removed these files, and compiled the above program again. Then it worked without errors.

2017-01-19 19:04:44 -0600 received badge  Critic (source)
2017-01-18 22:00:33 -0600 asked a question cv::VideoCapture::open(file) causes fatal memory error

Hello. After upgrading Ubuntu to trusty, a simple video-load code became producing fatal memory error. The code is just opening an video file:

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
int main(int argc, char**argv)
{
  std::string path="sample/vout2l.avi";
  cv::VideoCapture vin(path);
  return 0;
}

Executing this causes a fatal memory error:

*** Error in `./cv2-videoread.out': free(): invalid next size (fast): 0x000000000217b590 ***
Abort (core dumped)

I compiled this code with OpenCV 2.4.8 and 2.4.13; both cases finished with the above error.

The backtrace by gdb was:

#0  0x00007fc80d659c37 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x00007fc80d65d028 in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2  0x00007fc80d6962a4 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#3  0x00007fc80d6a255e in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#4  0x00007fc80d6a42ef in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#5  0x00007fc80d6a5ba4 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#6  0x00007fc80d6a77d2 in posix_memalign () from /lib/x86_64-linux-gnu/libc.so.6
#7  0x00007fc8092d10fe in av_malloc () from /usr/lib/x86_64-linux-gnu/libavutil.so.52
#8  0x00007fc809512708 in ?? () from /usr/lib/x86_64-linux-gnu/libavformat.so.54
#9  0x00007fc8095139b3 in avio_open2 ()
  from /usr/lib/x86_64-linux-gnu/libavformat.so.54
#10 0x00007fc8095b69e3 in avformat_open_input ()
  from /usr/lib/x86_64-linux-gnu/libavformat.so.54
#11 0x00007fc80df30584 in CvCapture_FFMPEG::open(char const*) ()
  from /usr/lib/libopencv_highgui.so.2.4
#12 0x00007fc80df30719 in cvCreateFileCapture_FFMPEG ()
  from /usr/lib/libopencv_highgui.so.2.4
#13 0x00007fc80df32ac9 in cvCreateFileCapture_FFMPEG_proxy(char const*) ()
  from /usr/lib/libopencv_highgui.so.2.4
#14 0x00007fc80df1ad89 in cvCreateFileCapture ()
  from /usr/lib/libopencv_highgui.so.2.4
#15 0x00007fc80df1b045 in cv::VideoCapture::open(std::string const&) ()
  from /usr/lib/libopencv_highgui.so.2.4
---Type <return> to continue, or q <return> to quit---
#16 0x00000000004008a2 in main (argc=<optimized out>, argv=<optimized out>)
    at cv2-videoread.cpp:32

It seemed that the issue was caused by libavformat and/or libavutil, so I reinstalled them but it didn't work.

If you have any ideas to fix this issue or investigate more, please let me know. I'm struggling with this issue for these several months.

Many thanks.

2016-06-28 10:40:36 -0600 commented question Mat::at operator with single index

berak, let's make the reason clear. OpenCV does NOT guarantee a continuous memory allocation. When the memory is not allocated continuously, a low-level block access like m.at<float[3]>(i) or m.at<cv::Vec3f>(i) is dangerous and should be avoided as you say. However OpenCV provides Mat::isContinuous to check if the memory allocation is continuous or not. So when the memory allocation is continuous, those block accesses could be acceptable. Are there other points?

2016-06-27 23:56:35 -0600 commented question Mat::at operator with single index

berak, with m.at<float[3]>, I am trying to get a row, which will return float[3]. So I stored it into a pointer float*.

2016-06-27 23:54:53 -0600 commented question Mat::at operator with single index

LBerger, I understand that when we use Mat::at, we have to know the element type and size (above, it's float, 4 byte). So I wrote like m.at<cv::vec3f> since I knew the type and the size.

2016-06-27 14:16:53 -0600 asked a question Mat::at operator with single index

Although the OpenCV documents say:

Mat::at

the variants with a single index (i) can be used to access elements of single-row or single-column 2-dimensional arrays

we can use Mat::at with a single index for usual MxN matrix.

e.g.

cv::Mat m(3,3,CV_32F);
float *p1(m.at<float[3]>(0));
p1[0]=...; p1[1]=...; p1[2]=...;
cv::Vec3f &p2(m.at<cv::Vec3f>(1));
p2[0]=...; p2[1]=...; p2[2]=...;

This way is useful to me. My question is: Is this not a regular way? If OpenCV changes the implementation and restricts the above style, then I would have a trouble.

Edited:

What I want to do is getting a row without a big overhead. I'm seeking a way lighter than m.row(i) (which takes cv::Mat overhead). I am assuming a case where the number of columns is known, like above case (3). In such a case, I think we could get a pointer to an array block (float[3] or cv::Vec3f) at i-th row.

2016-06-13 19:30:00 -0600 received badge  Student (source)
2016-06-13 18:18:42 -0600 received badge  Scholar (source)
2016-06-13 17:05:32 -0600 asked a question Multiplication between Mat and Scalar

For a given mask image (binary cv::Mat M), I'd like to color (cv::Scalar C) the white pixels of M. In general, I think this problem is an element-wise multiplication between cv::Mat and cv::Scalar, like:

M2 = M*C

where I am expecting:

[0 1 0 ...]                     [Scalar(0,0,0) Scalar(b,g,r) Scalar(0,0,0) ...]
[0 1 1 ...]  * Scalar(b,g,r) =  [Scalar(0,0,0) Scalar(b,g,r) Scalar(b,g,r) ...]
[0 0 0 ...]                     [Scalar(0,0,0) Scalar(0,0,0) Scalar(0,0,0) ...]

but actually there is no definition of operator* between cv::Mat and cv::Scalar. What is a good alternative?

Computing an image for each channel (i.e. M*b, M*g, M*r) and then compose a single image by cv::merge would be a solution, but I feel it might not be computationally efficient. (or is this a best way?)

2016-04-21 14:48:56 -0600 received badge  Enthusiast
2016-04-04 02:25:55 -0600 received badge  Self-Learner (source)
2016-04-01 16:23:59 -0600 received badge  Editor (source)
2016-04-01 16:14:09 -0600 answered a question Stereo calibration for beginners

A camera calibration tool implemented on ROS (Robot Operating System) was easy to use.

camera_calibration/Tutorials/Stereo Calibration:
http://wiki.ros.org/camera_calibratio...

Although for me this tool would be enough, its source code is available online (written in Python though).

Other good pages were:

Jay Rambhia: Stereo Calibration (introduced by #StevenPuttemans)
http://www.jayrambhia.com/blog/stereo...

OpenCV documentation: Camera calibration With OpenCV
http://docs.opencv.org/2.4/doc/tutori...

2016-04-01 16:07:16 -0600 commented question Stereo calibration for beginners

Thank you so much for the pages!

2016-03-30 14:28:56 -0600 asked a question Stereo calibration for beginners

Hello, I'd like to make a stereo program in C++ with OpenCV 2.4. I just tested cv::StereoBM and cv::StereoSGBM without calibration, but the result was inaccurate.

Could you give me good references (URLs) written about recent stereo calibration with OpenCV? I also want some sample codes.

Although I googled stereo calibration with OpenCV, there are many resources including old ones, someone's trials, I couldn't find a good reference. Please recommend a good introduction.

Thanks! -- Akihiko