0

장면에서 발견되는 기준점을 기준으로 카메라 포즈를 결정하려고합니다.카메라 포즈를 결정 하시겠습니까?

케이트 표준 : http://tinypic.com/view.php?pic=4r6k3q&s=8#.VNLnWTVVK1E

현재 공정 :

  • 이 CV_RANSAC를 사용하여 호모 그래피를 찾기 일치를위한 특징 검출 기술자 추출을위한
  • 사용 SIFT에 대한

    1. 사용 SIFT
    2. 사용 플란넬
    3. 기점의 모서리 식별
    4. perspectiveTransform()을 사용하여 장면에서 기점의 모서리 식별
    5. 모서리를 중심으로 선을 그립니다. 그것이 지금은 포즈 카메라를 알아 내려고 노력하고있는 장면
    6. 실행 카메라 보정에
    7. 로드 교정 결과 (cameraMatrix & distortionCoefficients)

    을 기점를 발견 증명한다.

    무효 solvePnP (const를 매트 & objectPoints, const를 매트 & imagePoints, const를 매트 & cameraMatrix, const를 매트 & distCoeffs, 매트 & rvec, 매트 & tvec, 부울 useExtrinsicGuess = false)를

    : 내가 사용하려고

    여기서

    • obectPoints는 기준점 코너는
    • imagePoints는
    • cameraMatrix는
    • distCoeffs 교정에서입니다 교정에서있는 장면의 기준점 코너입니다 rvec 및 tvec는

    그러나이 기능에서 나에게 반환해야

  • , 나는이 실행 , 코어 덤프 에러가 발생하여, 내가 뭘 잘못하고 있는지 확실하지 않습니다.

    solvePNP()에 대한 문서를 찾지 못했습니다. 함수 나 입력 매개 변수를 잘못 이해 했습니까?

    업데이트를 당신의 도움이 여기에 을 감사합니다 내 프로세스입니다

    OrbFeatureDetector detector; //Orb seems more accurate than SIFT 
    vector<KeyPoint> keypoints1, keypoints2; 
    
    detector.detect(marker_im, keypoints1); 
    detector.detect(scene_im, keypoints2); 
    
    Mat display_marker_im, display_scene_im; 
    drawKeypoints(marker_im, keypoints1, display_marker_im, Scalar(0,0,255)); 
    drawKeypoints(scene_im, keypoints2, display_scene_im, Scalar(0,0,255)); 
    
    SiftDescriptorExtractor extractor; 
    Mat descriptors1, descriptors2; 
    
    extractor.compute(marker_im, keypoints1, descriptors1); 
    extractor.compute(scene_im, keypoints2, descriptors2); 
    
    BFMatcher matcher; //BF seems to match better than FLANN 
    vector<DMatch> matches; 
    matcher.match(descriptors1, descriptors2, matches); 
    
    Mat img_matches; 
    drawMatches(marker_im, keypoints1, scene_im, keypoints2, 
        matches, img_matches, Scalar::all(-1), Scalar::all(-1), 
        vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS); 
    
    vector<Point2f> obj, scene; 
    for (int i = 0; i < matches.size(); i++) { 
        obj.push_back(keypoints1[matches[i].queryIdx].pt); 
        scene.push_back(keypoints2[matches[i].trainIdx].pt); 
    } 
    
    Mat H; 
    H = findHomography(obj, scene, CV_RANSAC); 
    
    //Get corners of fiducial 
    vector<Point2f> obj_corners(4); 
    obj_corners[0] = cvPoint(0,0); 
    obj_corners[1] = cvPoint(marker_im.cols, 0); 
    obj_corners[2] = cvPoint(marker_im.cols, marker_im.rows); 
    obj_corners[3] = cvPoint(0, marker_im.rows); 
    vector<Point2f> scene_corners(4); 
    
    perspectiveTransform(obj_corners, scene_corners, H); 
    
    FileStorage fs2("cal.xml", FileStorage::READ); 
    
    Mat cameraMatrix, distCoeffs; 
    fs2["Camera_Matrix"] >> cameraMatrix; 
    fs2["Distortion_Coefficients"] >> distCoeffs; 
    
    Mat rvec, tvec; 
    
    //same points as object_corners, just adding z-axis (0) 
    vector<Point3f> objp(4); 
    objp[0] = cvPoint3D32f(0,0,0); 
    objp[1] = cvPoint3D32f(gray.cols, 0, 0); 
    objp[2] = cvPoint3D32f(gray.cols, gray.rows, 0); 
    objp[3] = cvPoint3D32f(0, gray.rows, 0); 
    
    solvePnPRansac(objp, scene_corners, cameraMatrix, distCoeffs, rvec, tvec); 
    
    Mat rotation, viewMatrix(4, 4, CV_64F); 
    Rodrigues(rvec, rotation); 
    
    for(int row=0; row<3; ++row) 
    { 
        for(int col=0; col<3; ++col) 
        { 
         viewMatrix.at<double>(row, col) = rotation.at<double>(row, col); 
        } 
        viewMatrix.at<double>(row, 3) = tvec.at<double>(row, 0); 
    } 
    
    viewMatrix.at<double>(3, 3) = 1.0f; 
    
    cout << "rotation: " << rotation << endl; 
    cout << "viewMatrix: " << viewMatrix << endl; 
    
  • 답변

    0

    좋아, solvePnP() 당신에게 카메라에 모델의 프레임에서 전송 매트릭스 (즉, 큐브를) 제공 프레임 (뷰 매트릭스라고도 함).

    입력 파라미터 :

    • objectPoints - 객체의 객체 포인트의 배열 좌표 공간 3XN/NX3 1 채널 또는 1xN/NX1 N 포인트의 수를 3 채널. std::vector<cv::Point3f>도 여기에 전달할 수 있습니다. 점은 3D이지만, (기준점 마커의) 패턴 좌표계에 있기 때문에 각 입력 물체 점의 Z 좌표가 0이되도록 평면이 평면입니다.
    • imagePoints - 해당 이미지 점의 배열, 2xN/Nx2 1 채널 또는 1xN/Nx1 2 채널. 여기서 N은 포인트의 수입니다. std::vector<cv::Point2f> 또한, 여기에서 전달 될 수
    • intrinsics : 카메라 행렬 (초점 거리, 주점)
    • distortion : 왜곡 계수들은 제로 왜곡 계수가 비어 있으면 가정,
    • rvec : 출력 회전 벡터
    • tvec :

      : 출력 변환 벡터 뷰 행렬의

    건물의이 같은 것입니다

    cv::Mat rvec, tvec; 
    cv::solvePnP(objectPoints, imagePoints, intrinsics, distortion, rvec, tvec); 
    cv::Mat rotation, viewMatrix(4, 4, CV_64F); 
    cv::Rodrigues(rvec, rotation); 
    
    for(int row=0; row<3; ++row) 
    { 
        for(int col=0; col<3; ++col) 
        { 
         viewMatrix.at<double>(row, col) = rotation.at<double>(row, col); 
        } 
    
        viewMatrix.at<double>(row, 3) = tvec.at<double>(row, 0); 
    } 
    
    viewMatrix.at<double>(3, 3) = 1.0f; 
    

    또한 코드 및 오류 메시지를 공유 할 수 있습니까?

    +0

    그것은 교정 체스 판의 외부 매개 변수를 찾습니다. 기준점을 기준으로 카메라 포즈를 찾으려고했습니다. 아니면 내가 너를 오해하고 있니? – P3d0r

    +0

    오케이, 나는 너를 오해하고있다. 미안하다. 답변이 수정되었습니다. – Kornel

    +0

    코드에 추가 된 부분 – P3d0r