2017-10-18 18 views
0

로봇 프로젝트에서 작업 중입니다. 핵심 포인트를 감지하고이 포인트의 좌표를 가져와 조작 할 로봇으로 전송해야합니다. 나는 카메라 교정을하고 교정 정보를 사용하여 카메라에서 이미지의 왜곡을 제거한 다음 ORB 기술을 적용하여 핵심 사항을 찾아 냈습니다. 지금까지 모든 것이 좋지만 로봇과 함께 작동하기 위해 이러한 핵심 포인트 좌표를 매핑하는 방법을 모르겠습니다.픽셀 좌표를 세계 좌표로 변환하는 방법은 무엇입니까?

int main(int argc, char** argv) 
{ 

std::vector<KeyPoint> kp; 
Mat frame; 
Mat frame_un; 
Mat camera_matrix =(Mat_<double>(3,3) << 7.4191833420713715e+02, 0.0, 320.0, 0.0, 7.4191833420713715e+02, 240.0, 0.0, 0.0, 
    1.0); 
Mat distortion_coefficients =(Mat_<double>(5,1) << -1.5271566741564191e-01, 1.5488166759164064e+00, 0.0, 0.0, 
    -7.6517765981508861e+00); 

VideoCapture cap(1); // open the default camera 
if (!cap.isOpened()) // check if we succeeded 
    return -1; 

for (;;) 
{ 

    cap.read(frame); // get a new frame from camera 
    if (frame.empty()) 
continue; 
undistort(frame, frame_un, camera_matrix, distortion_coefficients); 
// Default parameters of ORB 
    int nfeatures=30; 
    float scaleFactor=1.2f; 
    int nlevels=8; 
    int edgeThreshold=31; // Changed default (31); 
    int firstLevel=0; 
    int WTA_K=2; 
    int scoreType=ORB::HARRIS_SCORE; 
    int patchSize=31; 
    int fastThreshold=20; 

Ptr<ORB> detector = ORB::create(
    nfeatures, 
    scaleFactor, 
    nlevels, 
    edgeThreshold, 
    firstLevel, 
    WTA_K, 
    scoreType, 
    patchSize, 
    fastThreshold); 

    detector->detect(frame_un, kp); 
    std::cout << "Found " << kp.size() << " Keypoints " << std::endl; 
for(int i=0; i<=kp.size();i++) 
{ 
int x = kp[i].pt.x; 
int y = kp[i].pt.y; 
cout << "Point "<<i<<" Xpos = " << x << " Point "<<i<< " Ypos = " << y << "\n"; 

}  
Mat out; 

    //drawKeypoints(img, kp, out, Scalar::all(255)); 
drawKeypoints(frame_un, kp, out, Scalar::all (255)); 
namedWindow("Kpts", WINDOW_FREERATIO); 
    imshow("Kpts", out); 
waitKey(0); 
destroyWindow("Kpts"); 
} 
    // waitKey(0); 
    return 0; 
} 
+0

이러한 방식으로 키포인트를 사용할 수있는 많은 방법이 있습니다. odometry 또는 다른 것에 관심이 있습니까? 일반화 된 용어는 동음 이의어라고 생각합니다. – jdv

+0

그래서 호모 그래피 기술을 사용하면이 좌표를 실제 좌표로 매핑하여 조작자가 조작 할 수 있습니다. – Ahmad

+0

확실합니다. 여기에 대한 몇 가지 논의가 있습니다 : https://stackoverflow.com/q/30502687/1531971 (및 기타)이 질문은 약간 넓을 수도 있고, 더 많은 연구가 필요하다고 생각합니다. – jdv

답변

0

그냥 좌표계 로봇의베이스 좌표계를 매핑과 기원합니다 여기

내가 사용하고 코드입니다. 이렇게하기 전에 mm 정확도로 시력을 올바르게 보정했는지 확인하십시오.