Ask Your Question

wr43th13's profile - activity

2019-11-11 09:49:21 -0600 commented answer Segmentation fault from DetectorParameters[SOLVED]

Yeah this fixes it. Not sure why opencv doc page doesn't assign anything to the params (i.e. Ptr<aruco::DetectorParam

2019-11-11 09:48:17 -0600 received badge  Supporter (source)
2019-11-11 09:48:15 -0600 marked best answer Segmentation fault from DetectorParameters[SOLVED]

In the code below, similar to the one found in this opencv (ch)aruco board detection doc, i get a segmentation fault from lines involving the DetectorParameters (except the declaration) data structure. Commenting the lines params->cornerRefinementMethod = aruco::CORNER_REFINE_NONE; and aruco::detectMarkers(image, dictionary, corners, ids, params); results in no segmentation fault when executing. I can see the images from the camera (without detecting markers of course).

// charuco board generation
    Ptr<aruco::CharucoBoard> board = aruco::CharucoBoard::create(
        5, 
        7, 
        0.04, 
        0.02, 
        dictionary);
    Mat boardImage;
    board->draw({640, 480}, boardImage, 10, 1);
    imwrite("ArucoBoard.png", boardImage);


    //detection
    VideoCapture inputVideo(0);

    if(!inputVideo.isOpened())  // check if we succeeded
    {        
        cout << "Camera Init Fail\n";
        return -1;
    }

    cout<<"\nAfter check"<<endl;

    Ptr<aruco::DetectorParameters> params;
    params->cornerRefinementMethod = aruco::CORNER_REFINE_NONE;

    cout<<"\nBefore while"<<endl;

    while (inputVideo.grab()) {

        Mat image, imageCopy;
        inputVideo.retrieve(image);
        image.copyTo(imageCopy);

        cout<<"\nCopied image"<<endl;

        vector<int> ids;
        vector<vector<Point2f>> corners;
        aruco::detectMarkers(image, dictionary, corners, ids, params);

        cout<<"\nDetected markers"<<endl;

        // if at least one marker detected
        if (ids.size() > 0) {
            aruco::drawDetectedMarkers(imageCopy, corners, ids);
            vector<Point2f> charucoCorners;
            vector<int> charucoIds;
            aruco::interpolateCornersCharuco(corners, ids, image, board, charucoCorners, charucoIds);
            // if at least one charuco corner detected
            if(charucoIds.size() > 0)
                aruco::drawDetectedCornersCharuco(imageCopy, charucoCorners, charucoIds, Scalar(255, 0, 0));
        }
        imshow("out", imageCopy);
        char key = (char) waitKey(25);
        if (key == 27)
            break;
2019-11-11 09:48:15 -0600 received badge  Scholar (source)
2019-11-11 09:48:15 -0600 commented answer Segmentation fault from DetectorParameters[SOLVED]

Yeah this fixes it. Not sure why opencv doc page doesn't assign anything to the params. Thanks, begginer's mistake.

2019-11-11 09:32:13 -0600 edited question Segmentation fault from DetectorParameters[SOLVED]

Segmentation fault from DetectorParameters In the code below, similar to the one found in this opencv (ch)aruco board de

2019-11-11 09:32:09 -0600 edited question Segmentation fault from DetectorParameters[SOLVED]

Segmentation fault from DetectorParameters In the code below, similar to the one found in this opencv (ch)aruco board de

2019-11-11 09:31:18 -0600 edited question Segmentation fault from DetectorParameters[SOLVED]

Segmentation fault from DetectorParameters In the code below, similar to the one found in this opencv (ch)aruco board de

2019-11-11 09:31:12 -0600 received badge  Editor (source)
2019-11-11 09:31:12 -0600 edited question Segmentation fault from DetectorParameters[SOLVED]

Segmentation fault from DetectorParameters In the code below, similar to the one found in this opencv (ch)aruco detectio

2019-11-11 09:26:21 -0600 asked a question Segmentation fault from DetectorParameters[SOLVED]

Segmentation fault from DetectorParameters In the code below, similar to the one found in this opencv (ch)aruco detectio