Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does it support other image format? #53

Open
niraj-bhujel opened this issue Jan 23, 2020 · 3 comments
Open

Does it support other image format? #53

niraj-bhujel opened this issue Jan 23, 2020 · 3 comments

Comments

@niraj-bhujel
Copy link

niraj-bhujel commented Jan 23, 2020

I get error when executing
~/libSGM/build/sample/image$ ./stereo_test image_left.png image_right.png. The images are in folder /libSGM/sample/image/.
It throws error input image format must be CV_8U or CV_16U Wonder does it support other image format other than .pgm? I am on Ubuntu 16.04, Cmake 3.5.1, Opencv 3.4.0, Python 3.5. Thanks in advance!

@atakagi-fixstars
Copy link
Contributor

Hi, @niraj-bhujel

Any format is OK, but requires single channel grayscale images.

I guess you are using color images?
If so, you need to convert the images to grayscale like this.

cv::Mat  left = cv::imread(parser.get<cv::String>("@left_img"), -1);
cv::Mat right = cv::imread(parser.get<cv::String>("@right_img"), -1);

cv::cvtColor(left, left, cv::COLOR_BGR2GRAY);
cv::cvtColor(right, right, cv::COLOR_BGR2GRAY);

Regards,

@niraj-bhujel
Copy link
Author

Okay. Thanks a lot @atakagi-fixstars . It is working now!! Is there a way to save disparity map?

@atakagi-fixstars
Copy link
Contributor

@niraj-bhujel

Is there a way to save disparity map?

You can use cv::imwrite.

ssgm.execute(left.data, right.data, disparity.data);
cv::imwrite("disparity.png", disparity);

Regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants