partner-gitlab已接入小米账号,使用详情见用户手册

Commit 4cf0b791 authored by 李卫硕's avatar 李卫硕

change screen fov

parent 4f695ed3
......@@ -488,8 +488,8 @@ bool HmdCalibratorInteraction::read_screen_uv(){
bool HmdCalibratorIndustry::GetCaibCorrespondence(const cv::Mat& chessboard_screen,const cv::Mat& chessboard_eyecamera,cv::Size chessboard_pattern, DeviceType& type){
double fy_screen = (2*_glassinfo->_f_render *tan(degree2radian(_glassinfo->vfov_l/2.0f)))/float(IMAGEHEIGHT);
double fx_screen = fy_screen;//
// double fx_temp= (2*_glassinfo->_f_render *tan(degree2radian(_glassinfo->hfov_l/2.0f)))/float(IMAGEWIDTH);
// double fx_screen = fy_screen;
double fx_screen = (2*_glassinfo->_f_render *tan(degree2radian(_glassinfo->hfov_l/2.0f)))/float(IMAGEWIDTH);
cv::Mat gray_chessborad_screen;
cv::Mat gray_chessboard_eyecamera;
......
......@@ -4,7 +4,12 @@ target_link_libraries(calib_stereo_fisheye_cam
${OpenCV_LIBS}
GlobImage
)
add_executable(draw_chessboard ./calib_camera_tools/draw_chessboard.cpp)
target_link_libraries(draw_chessboard
CALIB_GLASS
${OpenCV_LIBS}
GlobImage
)
add_executable(calib_stereo_pinhole ./calib_camera_tools/calib_stereo_pinhole.cpp)
target_link_libraries(calib_stereo_pinhole
CALIB_GLASS
......
......@@ -11,6 +11,9 @@ using namespace cv;
#define DEBUG_INFO
#define SHOW_IMAGE
cv::String left_pattern,right_pattern,result_dir;
vector< vector< Point3d > > object_points;
vector< vector< Point2f > > imagePoints1, imagePoints2;
vector< Point2f > corners1, corners2;
......@@ -76,10 +79,11 @@ const std::vector<std::string>& right_file) {
}
}
void save_data(const cv::Mat &K1, const cv::Mat &K2, const cv::Mat&R,
const cv::Mat &T,const cv::Mat &D1, const cv::Mat &D2)
const cv::Mat &T,const cv::Mat &D1, const cv::Mat &D2,const double &error)
{
std::cout<<"Save the calibr result ..."<<std::endl;
cv::FileStorage fs_write("/home/mi/lws_pkg/data/glass_kalibr/kalibr_result/fisheye.yaml", cv::FileStorage::WRITE);
cv::FileStorage fs_write(result_dir, cv::FileStorage::WRITE);
fs_write << "kalibr_error " <<error;
fs_write << "left_K " << Mat(K1);
fs_write << "right_k " << Mat(K2);
fs_write << "left_distortion " << D1;
......@@ -89,13 +93,29 @@ void save_data(const cv::Mat &K1, const cv::Mat &K2, const cv::Mat&R,
}
int main(){
cv::String left_pattern = "/home/mi/lws_pkg/data/glass_kalibr/3.17/fish_intrinsic/cam0/data/*.png";
cv::String right_pattern = "/home/mi/lws_pkg/data/glass_kalibr/3.17/fish_intrinsic/cam1/data/*.png";
cv::FileStorage start_fs("/home/mi/2022/data/glass_kalibr/4.8/start.yaml", cv::FileStorage::READ);
int board_width,board_height;
float square_size;
if (!start_fs.isOpened())
{
std::cout<<"start_fs: "<<start_fs.isOpened()<<std::endl;
return false;
}
else{
std::cout<<"Load parames"<<std::endl;
start_fs["fisheye_left_img_dir"]>>left_pattern;
start_fs["fisheye_right_img_dir"]>>right_pattern;
start_fs["fisheye_result_dir"]>>result_dir;
start_fs["chessboard_width"]>>board_width;
start_fs["chessboard_heght"]>>board_height;
start_fs["chessboard_size"]>>square_size;
}
std::vector<std::string> left_file = GLOB::GlobImage::ReadImage(left_pattern);
std::vector<std::string> right_file = GLOB::GlobImage::ReadImage(right_pattern);
int board_width = 11;
int board_height = 8;
float square_size = 0.035;
// int board_width = 11;
// int board_height = 8;
// float square_size = 0.035;
load_image_points( board_width,board_height,square_size, left_file, right_file);
cv::Mat K1 = cv::Mat::eye(3,3,CV_32FC1);
......@@ -111,10 +131,10 @@ int main(){
double error = cv::fisheye::stereoCalibrate(object_points, left_img_points, right_img_points,
K1, D1, K2, D2, img1.size(), R, T, flag,
cv::TermCriteria(3, 12, 0));
save_data(K1,K2,R,T,D1,D2);
#ifndef DEBUG_INFO
save_data(K1,K2,R,T,D1,D2,error);
std::cout<<"error: "<<error<<std::endl;
#ifndef DEBUG_INFO
std::cout << "K1" << Mat(K1)<<std::endl;
std::cout << "K2" << Mat(K2)<<std::endl;
std::cout << "D1" << D1<<std::endl;
......
......@@ -12,6 +12,8 @@
using namespace std;
using namespace cv;
cv::String left_pattern,right_pattern,result_dir;
vector< vector< Point3f > > object_points;
vector< vector< Point2f > > imagePoints1, imagePoints2;
vector< Point2f > corners1, corners2;
......@@ -100,10 +102,11 @@ const std::vector<std::string>& right_file) {
}
void save_data(const cv::Mat &K1, const cv::Mat &K2, const cv::Mat&R,
const cv::Mat &T,const cv::Mat &D1, const cv::Mat &D2)
const cv::Mat &T,const cv::Mat &D1, const cv::Mat &D2,const double &error)
{
std::cout<<"Save the calibr result ..."<<std::endl;
cv::FileStorage fs_write("/home/mi/lws_pkg/data/glass_kalibr/kalibr_result/pinhole.yaml", cv::FileStorage::WRITE);
cv::FileStorage fs_write(result_dir, cv::FileStorage::WRITE);
fs_write << "kalibr error" << error;
fs_write << "left_K " << Mat(K1);
fs_write << "right_k " << Mat(K2);
fs_write << "left_distortion " << D1;
......@@ -112,15 +115,34 @@ void save_data(const cv::Mat &K1, const cv::Mat &K2, const cv::Mat&R,
fs_write << "t_right_world " << T;
}
//left_pattern,right_pattern,result_dir;
int main(){
cv::String left_pattern = "/home/mi/lws_pkg/data/glass_kalibr/3.17/Data/left/*.bmp";
cv::String right_pattern = "/home/mi/lws_pkg/data/glass_kalibr/3.17/Data/right/*.bmp";
cv::FileStorage start_fs("/home/mi/2022/data/glass_kalibr/4.8/start.yaml", cv::FileStorage::READ);
int board_width,board_height;
float square_size;
if (!start_fs.isOpened())
{
std::cout<<"start_fs: "<<start_fs.isOpened()<<std::endl;
return false;
}
else{
std::cout<<"Load parames"<<std::endl;
start_fs["industry_left_img_dir"]>>left_pattern;
start_fs["industry_right_img_dir"]>>right_pattern;
start_fs["industry_result_dir"]>>result_dir;
start_fs["chessboard_width"]>>board_width;
start_fs["chessboard_heght"]>>board_height;
start_fs["chessboard_size"]>>square_size;
std::cout<<"Finish Load parames "<<std::endl;
}
std::vector<std::string> left_file = GLOB::GlobImage::ReadImage(left_pattern);
std::vector<std::string> right_file = GLOB::GlobImage::ReadImage(right_pattern);
int board_width = 11;
int board_height = 8;
float square_size = 0.035;
// int board_width = 11;
// int board_height = 8;
// float square_size = 0.035;
load_image_points( board_width,board_height,square_size, left_file, right_file);
cv::Mat K1 = cv::Mat::eye(3,3,CV_32FC1);
cv::Mat K2 = cv::Mat::eye(3,3,CV_32FC1);
......@@ -138,6 +160,7 @@ int main(){
double error = cv::stereoCalibrate(object_points, left_img_points, right_img_points,
K1, D1, K2, D2, img1.size(), R, T,E,F, flag,
cv::TermCriteria(3, 12, 0));
std::cout<<"error: "<<error<<std::endl;
#ifndef DEBUG_INFO
std::cout<<"error: "<<error<<std::endl;
std::cout << "K1" << Mat(K1)<<std::endl;
......@@ -150,7 +173,7 @@ int main(){
printf("Starting PineHole Stereo Rectification\n");
#endif
save_data(K1,K2,R,T,D1,D2);
save_data(K1,K2,R,T,D1,D2,error);
cv::Mat R1, R2, P1, P2, Q;
cv::stereoRectify(K1, D1, K2, D2, img1.size(), R, T, R1, R2, P1, P2,
Q, cv::CALIB_ZERO_DISPARITY);
......
......@@ -3,11 +3,15 @@
#include <stdio.h>
#define DEBUG_INFO
std::string fisheye_kalibr_result,industry_kalibr_result,unity_kalibr_result;
std::string external_industry_left,external_industry_right,external_fisheye_left,external_fisheye_right;
std::string screen_industry_left,screen_industry_right,screen_dispaly;
bool loadCalibrResult(HMDCLAIB::TrackingCameraInfo &trackingcameraInfo,HMDCLAIB::EyeCameraInfo &eyecameraInfo)
{
std::cout<<"Load calibr result ... "<<std::endl;
cv::FileStorage fisheye_fs("/home/mi/lws_pkg/data/glass_kalibr/kalibr_result/fisheye.yaml", cv::FileStorage::READ);
cv::FileStorage pinhole_fs("/home/mi/lws_pkg/data/glass_kalibr/kalibr_result/pinhole.yaml", cv::FileStorage::READ);
cv::FileStorage fisheye_fs(fisheye_kalibr_result, cv::FileStorage::READ);
cv::FileStorage pinhole_fs(industry_kalibr_result, cv::FileStorage::READ);
if (!fisheye_fs.isOpened() && !pinhole_fs.isOpened())
{
std::cout<<"pinhole_fs: "<<pinhole_fs.isOpened()<<" ,fisheye_fs"<<fisheye_fs.isOpened()<<std::endl;
......@@ -81,7 +85,7 @@ void saveOnlineUnity(Eigen::Vector3f &RzRxRy_l,Eigen::Vector3f RzRxRy_r ,Eigen::
HMDCLAIB::CalibResultInfo &result_info,HMDCLAIB::GlassInfo &glassInfo)
{
std::cout<<"Save the offline test data eigen format ..."<<std::endl;
cv::FileStorage fs_write("/home/mi/lws_pkg/data/glass_kalibr/kalibr_result/OnlineUnity.yaml", cv::FileStorage::WRITE);
cv::FileStorage fs_write(unity_kalibr_result, cv::FileStorage::WRITE);
//for test
{
cv::Mat K_screenl = cv::Mat::zeros(3,3,CV_32FC1);
......@@ -116,28 +120,58 @@ void saveOnlineUnity(Eigen::Vector3f &RzRxRy_l,Eigen::Vector3f RzRxRy_r ,Eigen::
fs_write << "t_r " << t_right;
}
fs_write << "glassInfo_hfov_l " << glassInfo.hfov_l;
fs_write << "glassInfo_vfov_l " << glassInfo.vfov_l;
fs_write << "glassInfo_hfov_r " << glassInfo.hfov_r;
fs_write << "glassInfo_hfov_r " << glassInfo.vfov_r;
fs_write << "glassInfo_hfov_l" << glassInfo.hfov_l;
fs_write << "glassInfo_vfov_l" << glassInfo.vfov_l;
fs_write << "glassInfo_hfov_r" << glassInfo.hfov_r;
fs_write << "glassInfo_vfov_r" << glassInfo.vfov_r;
fs_write << "glassInfo_f_render" << glassInfo._f_render;
}
int main(){
HMDCLAIB::TrackingCameraInfo trackingcameraInfo;//mono camera
HMDCLAIB::EyeCameraInfo eyecameraInfo;//industry camera
HMDCLAIB::GlassInfo glassInfo;
glassInfo.hfov_l = 34.86302148498197;
glassInfo.vfov_l = 19.61044958530236;
glassInfo.hfov_r = 34.86302148498197;
glassInfo.vfov_r = 19.61044958530236;
cv::FileStorage start_fs("/home/mi/2022/data/glass_kalibr/4.8/start.yaml", cv::FileStorage::READ);
if (!start_fs.isOpened())
{
std::cout<<"start_fs: "<<start_fs.isOpened()<<std::endl;
return false;
}
else{
std::cout<<"Load parames"<<std::endl;
start_fs["external_fisheye_left_img_dir"]>>external_fisheye_left;
start_fs["external_fisheye_right_img_dir"]>>external_fisheye_right;
start_fs["external_industry_left_img_dir"]>>external_industry_left;
start_fs["external_industry_right_img_dir"]>>external_industry_right;
start_fs["screen_img_dir"]>>screen_dispaly;
start_fs["screen_industry_left_img_dir"]>>screen_industry_left;
start_fs["screen_industry_right_img_dir"]>>screen_industry_right;
start_fs["fisheye_result_dir"]>>fisheye_kalibr_result;
start_fs["industry_result_dir"]>>industry_kalibr_result;
start_fs["unity_kalibr_result_dir"]>>unity_kalibr_result;
}
glassInfo.hfov_l = 34.16; //34.16
glassInfo.vfov_l = 19.84; //19.84
glassInfo.hfov_r = 34.16;
glassInfo.vfov_r = 19.84;
glassInfo._f_render = 0.35f;
if(!loadCalibrResult(trackingcameraInfo,eyecameraInfo))
return 0;
{
std::cout<<"load calibr result faild"<<std::endl;
return 0;
}
#ifndef DEBUG_INFO
std::cout<<"trackingcameraInfo.K_r "<<trackingcameraInfo.K_r<<std::endl;
......@@ -156,17 +190,17 @@ int main(){
#endif
std::string industry_wall_chessboard_left = "/home/mi/lws_pkg/data/glass_kalibr/3.17/industry/left.bmp";
std::string industry_wall_chessboard_right = "/home/mi/lws_pkg/data/glass_kalibr/3.17/industry/right.bmp";
// std::string industry_wall_chessboard_left = "/home/mi/2022/data/glass_kalibr/4.8/external_industry/left.bmp";
// std::string industry_wall_chessboard_right = "/home/mi/2022/data/glass_kalibr/4.8/external_industry/right.bmp";
std::string fisheye_wall_chessboard_left = "/home/mi/lws_pkg/data/glass_kalibr/3.17/ex_fisheye/left.png";
std::string fisheye_wall_chessboard_right = "/home/mi/lws_pkg/data/glass_kalibr/3.17/ex_fisheye/right.png";
// std::string fisheye_wall_chessboard_left = "/home/mi/2022/data/glass_kalibr/4.8/external_fisheye/cam0/data/4007965879971.png";
// std::string fisheye_wall_chessboard_right = "/home/mi/2022/data/glass_kalibr/4.8/external_fisheye/cam1/data/4007965879971.png";
cv::Mat img_industry_l = cv::imread(industry_wall_chessboard_left,cv::IMREAD_GRAYSCALE);
cv::Mat img_industry_r = cv::imread(industry_wall_chessboard_right,cv::IMREAD_GRAYSCALE);
cv::Mat img_industry_l = cv::imread(external_industry_left,cv::IMREAD_GRAYSCALE);
cv::Mat img_industry_r = cv::imread(external_industry_right,cv::IMREAD_GRAYSCALE);
cv::Mat img_fisheye_l = cv::imread(fisheye_wall_chessboard_left,cv::IMREAD_GRAYSCALE);
cv::Mat img_fisheye_r = cv::imread(fisheye_wall_chessboard_right,cv::IMREAD_GRAYSCALE);
cv::Mat img_fisheye_l = cv::imread(external_fisheye_left,cv::IMREAD_GRAYSCALE);
cv::Mat img_fisheye_r = cv::imread(external_fisheye_right,cv::IMREAD_GRAYSCALE);
// pnp
cv::Mat remap_pinhole_x_l,remap_pinhole_y_l,remap_pinhole_x_r,remap_pinhole_y_r;
......@@ -185,7 +219,7 @@ int main(){
cv::eigen2cv(eyecameraInfo.K_r,cv_K_r);
cv::eigen2cv(eyecameraInfo.D_r,cv_D_r);
cv::initUndistortRectifyMap(cv_K_r, cv_D_r, R_rect,cv_K_r, img_industry_r.size(), CV_16SC2, remap_pinhole_x_r, remap_pinhole_y_r);
cv_D_l = cv::Mat(4,1,CV_32FC1);
cv_D_r = cv::Mat(4,1,CV_32FC1);
......@@ -197,11 +231,14 @@ int main(){
cv::eigen2cv(trackingcameraInfo.K_r,cv_K_r);
cv::eigen2cv(trackingcameraInfo.D_r,cv_D_r);
cv::fisheye::initUndistortRectifyMap(cv_K_r, cv_D_r, R_rect,cv_K_r, img_fisheye_r.size(), CV_16SC2, remap_fisheye_x_r, remap_fisheye_y_r);
std::cout<<"load industry image"<<std::endl;
cv::remap(img_industry_l,img_industry_l,remap_pinhole_x_l, remap_pinhole_y_l,cv::INTER_LINEAR);
cv::remap(img_industry_r,img_industry_r,remap_pinhole_x_r, remap_pinhole_y_r,cv::INTER_LINEAR);
cv::remap(img_fisheye_l,img_fisheye_l,remap_fisheye_x_l, remap_fisheye_y_l,cv::INTER_LINEAR);
cv::remap(img_fisheye_r,img_fisheye_r,remap_fisheye_x_r, remap_fisheye_y_r,cv::INTER_LINEAR);
std::cout<<"load industry image"<<std::endl;
cv::Size board_size = cv::Size(11,8);
std::vector<cv::Point2f> corners_pinhole_l,corners_pinhole_r;
......@@ -315,11 +352,11 @@ int main(){
//-----------------------------------------step 2------------------------------------------------//
HMDCLAIB::HmdCalibratorIndustry HmdCalib(trackingcameraInfo,eyecameraInfo, glassInfo);
cv::Mat chessboard_screen_l,chessboard_eyecamera_l;
chessboard_screen_l = cv::imread("/home/mi/Downloads/BoardImage.jpg");
chessboard_eyecamera_l = cv::imread("/home/mi/lws_pkg/data/glass_kalibr/3.17/screen/left.bmp");
chessboard_screen_l = cv::imread(screen_dispaly);
chessboard_eyecamera_l = cv::imread(screen_industry_left);
cv::Mat chessboard_screen_r,chessboard_eyecamera_r;
chessboard_screen_r = cv::imread("/home/mi/Downloads/BoardImage.jpg");
chessboard_eyecamera_r = cv::imread("/home/mi/lws_pkg/data/glass_kalibr/3.17/screen/right.bmp");
chessboard_screen_r = cv::imread(screen_dispaly);
chessboard_eyecamera_r = cv::imread(screen_industry_right);
cv::Size chessboard_pattern = cv::Size(15,8);
HMDCLAIB::DeviceType type = HMDCLAIB::DeviceType::left; // what is this ??
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment