Comments (8)
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.
Hi, Thank you! I got it.
I use the code to transform my own image. The result is like this :
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.
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.
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;
};
from cam2bev.
Please understand that we cannot provide support for any work outside of our repository.
from cam2bev.
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.
Yes, that should be possible with the extrinsic rotation matrix. Our code also doesn't rotate images manually.
from cam2bev.
Thank you . I'll check it.
from cam2bev.
Related Issues (20)
- how to generate this simulated data
- Frame Rate HOT 4
- Training of deeplab-mobilenet and deeplab-xception failed HOT 2
- What changes to make to resume training from where it was left off? HOT 2
- Non-360 View HOT 10
- Frame rate HOT 2
- Training on original input HOT 2
- How to test on real-world images HOT 1
- Performance when evaluating custom data HOT 1
- some issue about "homography_converter" HOT 10
- What should the regularization coefficient be set to? HOT 1
- drone camera config file HOT 2
- A few questions about your work HOT 1
- 0
- Training on Google Colab HOT 2
- Real-world application HOT 1
- field of view single-input model HOT 2
- the R matrix calculate order may have some problem? HOT 1
- Model for testing HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cam2bev.