Coder Social home page Coder Social logo

BEV image about cam2bev HOT 8 CLOSED

ika-rwth-aachen avatar ika-rwth-aachen commented on July 25, 2024
BEV image

from cam2bev.

Comments (8)

lreiher avatar lreiher commented on July 25, 2024

Note that the extrinsic camera matrix [R | t] describes how to transform points in world coordinates to camera coordinates and not the other way round. I found a short article explaining in more depth where the t = -RX comes from.

from cam2bev.

loseyourself-gan avatar loseyourself-gan commented on July 25, 2024

Hi, Thank you! I got it.
I use the code to transform my own image. The result is like this :
image
I successfully transform the image, but they seem to in wrong direction . I need to rotate it to stitch the image. Dose it right ? Or I do something wrong . @lreiher

from cam2bev.

lreiher avatar lreiher commented on July 25, 2024

Hard to say by just looking at those images.

If you need further assistance, could you please post the exact command that you are executing and also attach the camera config files that you are using?

from cam2bev.

loseyourself-gan avatar loseyourself-gan commented on July 25, 2024

Actually, I use C++ to realize it. Here is my source code.the yml is same as your yml except for camera intrinsic matrix K.
The M is set to (1/50,0,-10,0,1/50,-10,0,0,0,0,0,1)
I use the camera extrinsic matrix and translation to realize it.
Thank you for your reply.

class camera{
public:
    camera(const char * _name){
        name = _name;
        std::string path = ymlpath + name;
        cv::FileStorage fs(path,cv::FileStorage::READ);
        if(!fs.isOpened()){
            std::cerr << "can not open the config yml!" << std::endl;
        }
        else{
            std::cout << "read config from the yml file" << std::endl;
        }
        cv::Mat K_,D_,R_,T_;
        fs["K"] >> K_;
        fs["D"] >> D_;
        fs["R"] >> R_;
        fs["T"] >> T_;
        cv::cv2eigen(K_,K);
        cv::cv2eigen(D_,D);
        cv::cv2eigen(R_,R0);
        cv::cv2eigen(T_,T);
        double roll,pitch,yaw;
        yaw = fs["yaw"];
        pitch = fs["pitch"];
        roll = fs["roll"];
        yaw = deg2rad(yaw);
        pitch = deg2rad(pitch);
        roll = deg2rad(roll);
        Eigen::Vector3d eulerAngle;
        eulerAngle << -roll,-pitch,-yaw;
        Eigen::AngleAxisd rollAngle(Eigen::AngleAxisd(eulerAngle(0),Eigen::Vector3d::UnitX()));
        Eigen::AngleAxisd pitchAngle(Eigen::AngleAxisd(eulerAngle(1),Eigen::Vector3d::UnitY()));
        Eigen::AngleAxisd yawAngle(Eigen::AngleAxisd(eulerAngle(2),Eigen::Vector3d::UnitZ()));
        Eigen::Matrix3d rotation_matrix;
        rotation_matrix=yawAngle*pitchAngle*rollAngle;
        cout << rotation_matrix.eulerAngles(0,1,2) << endl;

        R = rotation_matrix * R0;
        Eigen::Vector3d T1;
        T1 = -R * T;
        P.block<3,3>(0,0) = R;
        P.block<3,1>(0,3) = T1; 
        // P << R(0,0),R(0,1),T(0),
        //      R(1,0),R(1,1),T(1),
        //      R(2,0),R(2,1),T(2);
    };
    cv::Mat get_homography(Eigen::Matrix<double,4,3>&M,cv::Mat &image){
        Eigen::Matrix3d H,H_inv;
        cv::Mat h,dist;
        H = K * P * M;
        H_inv = H.inverse();
        cv::eigen2cv(H_inv,h);
        cv::warpPerspective(image,dist,h,image.size());
        return dist;
    }
    double deg2rad(double deg){
        return deg*M_PI/180;
    }
    cv::Mat undistort(cv::Mat & image){
        cv::Mat I0 = (cv::Mat_<double>(3,3)<< 1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0);
        cv::Mat K_cv,D_cv,map1,map2,un_image;
        cv::eigen2cv(K,K_cv);
        cv::eigen2cv(D,D_cv);
        cv::Mat dist = K_cv.clone();
        cv::fisheye::initUndistortRectifyMap(K_cv,D_cv,I0,dist,cv::Size(1000,800),CV_16SC2,map1,map2);
        cout << K.inverse() << endl;
        cv::remap(image,un_image,map1,map2,cv::INTER_LINEAR);
        return un_image;
    }


private:
    Eigen::Matrix3d K;
    Eigen::Matrix3d R;
    Eigen::Matrix3d R0;
    Eigen::Vector4d D;
    Eigen::Vector3d T;
    Eigen::Matrix<double,3,4>P;
    static const std::string ymlpath;
    const char * name;

};

@lreiher

from cam2bev.

lreiher avatar lreiher commented on July 25, 2024

Please understand that we cannot provide support for any work outside of our repository.

from cam2bev.

loseyourself-gan avatar loseyourself-gan commented on July 25, 2024

Anyway , thank you for your reply. If I do it right, can I stitch the image directly ? And I need not to rotate it manually. @lreiher

from cam2bev.

lreiher avatar lreiher commented on July 25, 2024

Yes, that should be possible with the extrinsic rotation matrix. Our code also doesn't rotate images manually.

from cam2bev.

loseyourself-gan avatar loseyourself-gan commented on July 25, 2024

Thank you . I'll check it.

from cam2bev.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.