Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ if(VLIB_FORCESLIM)
set(prophesee_core_FOUND OFF)
endif()

option(BUILD_ZYNQGRABBER "Build the zynqGrabber module" ON)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure why building zynqGrabber is related to IPT code? did we already discuss this?

@JiahangWu JiahangWu Jul 3, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for confusing you. Building zynqGrabber is not related to IPT. But it is related to building the event-driven on MAC. I didn't commit it before. I am going to commit it in another pull request.

add_subdirectory(cpp_tools)

#install the package
Expand Down
4 changes: 3 additions & 1 deletion cpp_tools/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
add_subdirectory(zynqGrabber)
if(BUILD_ZYNQGRABBER)
add_subdirectory(zynqGrabber)
endif()
add_subdirectory(hexViewer)

#add_subdirectory(binaryDumper)
Expand Down
50 changes: 42 additions & 8 deletions ev2/event-driven/vis/IPT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ bool vIPT::importIntrinsics(int cam, Bottle &parameters)
cam_matrix[cam].at<double>(2, 2) = 1.0;
cam_matrix[cam].at<double>(0, 2) = parameters.find("cx").asFloat64();
cam_matrix[cam].at<double>(1, 2) = parameters.find("cy").asFloat64();
if(cam == 0) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if no distortion model is provided?

distortion_model = parameters.find("distortion_model").asString();
}

dist_coeff[cam] = cv::Mat(4, 1, CV_64FC1);
dist_coeff[cam].at<double>(0, 0) = parameters.find("k1").asFloat64();
Expand Down Expand Up @@ -104,9 +107,19 @@ bool vIPT::computeForwardReverseMaps(int cam)
mat_reverse_map[cam] = cv::Mat(size_shared, CV_32FC2);

//mat_reverse_map fill
cv::initUndistortRectifyMap(cam_matrix[cam], dist_coeff[cam], rotation[cam],
projection[cam], size_shared, CV_32FC2,
mat_reverse_map[cam], cv::noArray());

if(distortion_model == "b'radtan'") {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it common knowledge that "b'radtan'" means pinhole, while "equidistant" means fisheye? Can we make sure this is more intuitive?

cv::initUndistortRectifyMap(cam_matrix[cam], dist_coeff[cam], rotation[cam],
projection[cam], size_shared, CV_32FC2,
mat_reverse_map[cam], cv::noArray());
} else if (distortion_model == "equidistant") {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if no distortion model is provided? or if there is a spelling mistake in the distortion model? seg fault?

std::vector<cv::Mat> maps(2);
cv::split(mat_reverse_map[cam], maps);
cv::fisheye::initUndistortRectifyMap(cam_matrix[cam], dist_coeff[cam], rotation[cam],
projection[cam], size_shared, CV_32F,
maps[0], maps[1]);
cv::merge(maps, mat_reverse_map[cam]);
}

if(mat_reverse_map[cam].empty()) {
yError() << "Camera Calibration failed";
Expand Down Expand Up @@ -164,6 +177,20 @@ const cv::Mat& vIPT::getQ(){
return Q;
}

const cv::Mat& vIPT::getK(int cam) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if cam = 2. we would return cam[0]? it could introduce error.
what about
if( cam == 0 || cam == 1 ) return cam_matrix[cam]
else return empty matrix?

if(cam == 1) {
return cam_matrix[1];
}
return cam_matrix[0];
}

const cv::Size& vIPT::getRes(int cam) {
if(cam == 1) {
return size_cam[1];
}
return size_cam[0];
}

bool vIPT::configure(const string &calib_file_path, int size_scaler)

{
Expand Down Expand Up @@ -192,12 +219,19 @@ bool vIPT::configure(const string &calib_file_path, int size_scaler)
//compute stereo + rectification

Q = cv::Mat(4, 4, CV_64FC1);

//Computing homographies for left and right image
cv::stereoRectify(cam_matrix[0], dist_coeff[0], cam_matrix[1],
dist_coeff[1], size_cam[0], stereo_rotation, stereo_translation,
rotation[0], rotation[1], projection[0],projection[1], Q,
CALIB_ZERO_DISPARITY, 1, size_shared);
if(distortion_model == "b'radtan'") {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also here - what happens if not provided or provided incorrectly

cv::stereoRectify(cam_matrix[0], dist_coeff[0], cam_matrix[1],
dist_coeff[1], size_cam[0], stereo_rotation, stereo_translation,
rotation[0], rotation[1], projection[0],projection[1], Q,
CALIB_ZERO_DISPARITY, 1, size_shared);
}
else if(distortion_model == "equidistant") {
cv::fisheye::stereoRectify(cam_matrix[0], dist_coeff[0], cam_matrix[1],
dist_coeff[1], size_cam[0], stereo_rotation, stereo_translation,
rotation[0], rotation[1], projection[0],projection[1], Q,
CALIB_ZERO_DISPARITY, size_shared);
}

} else {
if(valid_cam1)
Expand Down
3 changes: 3 additions & 0 deletions ev2/event-driven/vis/IPT.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class vIPT {
cv::Mat projection[2];
cv::Mat rotation[2];
cv::Mat Q;
std::string distortion_model;

cv::Mat point_forward_map[2];
cv::Mat point_reverse_map[2];
Expand All @@ -52,6 +53,8 @@ class vIPT {
vIPT();

const cv::Mat& getQ();
const cv::Mat& getK(int cam = 0);
const cv::Size& getRes(int cam = 0);
void setProjectedImageSize(int height, int width);
bool configure(const std::string &calib_file_path, int size_scaler = 2);
bool showMapProjections(double seconds = 0);
Expand Down