Ask Your Question

Roby's profile - activity

2017-08-18 08:19:22 -0600 asked a question IOS opencv memory rad failed for 0x0

when program go to a certain line, it goes to error: memory read failed for 0x0

stop at queue: com.apple.avfoundation.videodataoutput.bufferqueue(serial) thread 4 0 0x00000000

processImage:(Mat&)imagecall a class' method to do image processing. the error appears at class' method.

2017-04-24 01:07:31 -0600 received badge  Editor (source)
2017-04-24 00:47:55 -0600 asked a question Issues Compiling opencv3.2 with CUDA on Mac OS 10.12

My env and lib versions:

Mac OS 10.12,

opencv 3.2,

cuda8.0 ,

qt5 installed via brew,

Xcode8 & Xcode7(with CLT to compile cuda stuff)

I intended to install opencv3.2 by compiling source code.

cmake settings like below:

build without opencv_highgui & opencv_videoio(if these settings turned on, compiling would fail)

TURN OFF WITH_AVFOUNDATION,WITH_1394,WITH_QT ,WITH_QTKIT,WITH_QUICKTIME,WITH_TBB,WITH_IPP,WITH_GSTREAMER ..

TURN ON WITH_CUDA,WITH_EIGEN,WITH_JASPER,WITH_JPEG,WITH_LAPACK,WITH_OPENEXR,WITH_PNG,WITH_PTHREADS_PF,WITH_TIFF

with the setting as above compiled successfully!

but without opencv_highgui & opencv_videoio how can I show a image or read camera frames?

if I build opencv_videoio, and select any one of WITH_AVFOUNDATION, WITH_QTKIT,WITH_QUICKTIME will not successfully compiling.

errors like: (this error generate with quicktime FLAG)

~/openCV/opencv-3.2.0/modules/videoio/src/cap_qt.cpp:75:5: error: unknown type name 'Movie' Movie myMovie; // movie handle ^

~/openCV/opencv-3.2.0/modules/videoio/src/cap_qt.cpp:103:9: error: use of undeclared identifier 'EnterMovies' EnterMovies(); ^

~/openCV/opencv-3.2.0/modules/videoio/src/cap_qt.cpp:142:5: error: use of undeclared identifier 'ClearMoviesStickyError' ClearMoviesStickyError (); ^

2016-04-24 23:14:37 -0600 commented question Stereo Rectify doesn't rectify even with correct M and D

if your chessboards do not vary a lot(camera view angle to the chessboard's principle axis) in each image, you won't get the good intrinsic params( LM estimation won't converge to good result. all the input are similar and reduce the rank of Matrix). eventually after remaping image you get worse result.

2016-04-22 01:20:59 -0600 received badge  Enthusiast
2016-04-19 02:55:48 -0600 commented question Stereo Rectify doesn't rectify even with correct M and D

I think your issue is identical to mineprobem. it seems that your distortion model is not well set. in my problem it is not nessecery to use k6 in distortion model. your distortion model use k3 and k4 , i think it is not appropriate.

2016-04-18 20:59:19 -0600 commented question Stereo Rectify get incorrect result!

I finally get the reason.the distortion params used are not appropriate. set CALIB_FIX_K6 will get correct result. my test imgs are not distort severely, so it not nessecery to use K6 in distortion model.

2016-04-18 20:17:08 -0600 commented question Stereo Rectify get incorrect result!

yes. if you have any clue ,please let me know! thanks

2016-04-18 00:24:04 -0600 asked a question Stereo Rectify get incorrect result!

I am working on stereo calibration with these steps: 1. findChessborad -> cornerSubPix 2. stereoCalibrate to get R T E F 3.undistortPoints and computeCorrespondEpilines 4.stereoRectify to get R1 R2 P1 P2 Q 5.initUndistortRectifyMap to get remap matrix 6 remap

all the steps followed the cpp example given in the opencv package. one pair of images I used as below: image description image description

the result I get is: image description

if I use : findFundamentalMat and stereoRectifyUncalibrated instead of stereorectify to get R1 R2 P1 P2 will get a correct result.

here is my code snapshot:

//FOR STD LIB
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <iterator>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <sstream>

//FOR OPENCVLIB
#include "opencv2/opencv.hpp"
#include "opencv2/calib3d.hpp"
#include "opencv2/core/core.hpp"

#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv/cvaux.hpp"
//using namespace std;
//using namespace cv;


#define infinite 1e400
#define numImagePairs 10

const std::string PathPrefix = "/home/roby/Developer/projects/Calibration_rectify/res/";
typedef std::vector<std::string> ImageNameList;
typedef std::vector<cv::Point2f> PointList;
typedef std::vector<PointList> LEFT_PointVec;
typedef std::vector<PointList> RIGHT_PointVec;
typedef std::vector<std::vector<cv::Point3f> > Point3DList;
const cv::Size CHECKERBOARD_SIZE = cv::Size(7,6);


#define BYTE unsigned char

int main(int argc, const char * argv[])
{
    ImageNameList rightCameraList;
    ImageNameList leftCameraList;

    ImageNameList goodrightCameraList;
    ImageNameList goodleftCameraList;

    LEFT_PointVec leftCameraPTvec;
    RIGHT_PointVec rightCameraPTvec;
    Point3DList objectPoints;

    int numGoodImgPairs = numImagePairs;
    const float squareSize = 1.f;  // Set this to your actual square size
    cv::Size imageSize;

    //load image name
    std::ostringstream ss;

    for (int i = 1; i <= numImagePairs; i++) {
    ss << i;
        rightCameraList.push_back(PathPrefix + "right/right"+ss.str() +".png");
        leftCameraList.push_back(PathPrefix + "left/left"+ss.str() +".png");
        ss.str(""); //clear stream content
    }

    for (int i = 0; i < numImagePairs; i++) {
        cv::Mat rightimg = cv::imread(rightCameraList[i],0);
        cv::Mat leftimg = cv::imread(leftCameraList[i],0);
        if (rightimg.size != leftimg.size) {
            std::cout<<"Left Image size != Right Image Size"<<std::endl;
            return 0;
        }else{
            imageSize = rightimg.size();
        }

        rightimg.convertTo(rightimg, CV_8U);
        leftimg.convertTo(leftimg, CV_8U);

        PointList right_ptList;
        PointList left_ptList;

        if (cv::findChessboardCorners(rightimg, CHECKERBOARD_SIZE, right_ptList)) {
            if (cv::findChessboardCorners(leftimg, CHECKERBOARD_SIZE, left_ptList)) {
                cv::cornerSubPix(rightimg, right_ptList, cv::Size(11,11), cv::Size(-1,-1),
                                 cv::TermCriteria(cv::TermCriteria::COUNT+cv::TermCriteria::EPS,
                                          30, 0.01));
                cv::cornerSubPix(leftimg, left_ptList, cv::Size(11,11), cv::Size(-1,-1),
                                 cv::TermCriteria(cv::TermCriteria::COUNT+cv::TermCriteria::EPS,
                                          30, 0.01));
                rightCameraPTvec.push_back(right_ptList);
                leftCameraPTvec.push_back(left_ptList);
                goodleftCameraList.push_back(leftCameraList[i]);
                goodrightCameraList.push_back(rightCameraList[i]);
            }else{
                numGoodImgPairs--;
                std::cout<<"CHESSBOARD NOT FOUND in LEFT IMG!"<<std::endl;
            }
        }else{
            numGoodImgPairs--;
            std::cout<<"CHESSBOARD NOT FOUND in RIGHT IMG!"<<std::endl;
        }
    }

    if (numGoodImgPairs < 2) {
        std::cout<<"Error: too little pairs to run the calibration"<<std::endl;
        return 0;
    }
    objectPoints.resize(numGoodImgPairs);

    for( int i = 0; i < numGoodImgPairs; i++ )
    {
        for( int j = 0; j < CHECKERBOARD_SIZE.height; j++ )
            for( int k = 0; k < CHECKERBOARD_SIZE.width; k++ )
                objectPoints[i].push_back(cv::Point3f(k*squareSize, j*squareSize, 0));
    }
    cv::Mat cameraMatrix[2], distCoeffs[2];
    cameraMatrix[0] = cv::Mat ...
(more)