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

Unable to run tune_blockmatcher and image_to_pointcloud #21

Open
praneethshub opened this issue Feb 21, 2018 · 12 comments
Open

Unable to run tune_blockmatcher and image_to_pointcloud #21

praneethshub opened this issue Feb 21, 2018 · 12 comments

Comments

@praneethshub
Copy link

I am able to capture images on webcams and calibrate them well. But, while trying for execution of tune_blockmatcher and images_to_pointcloud, i found below errors as StereoBM and StereoSGBM classes are unable to import.

>import cv2
>from stereovision.blockmatchers import StereoBM, StereoSGBM
Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
 File "C:\Python27\lib\site-packages\stereovision\blockmatchers.py", line 111,
in <module>
   class StereoBM(BlockMatcher):
 File "C:\Python27\lib\site-packages\stereovision\blockmatchers.py", line 117,
in StereoBM
   "stereo_bm_preset": cv2.STEREO_BM_NARROW_PRESET}
AttributeError: 'module' object has no attribute 'STEREO_BM_NARROW_PRESET'
>`

My OS is Windows7, running OPENCV 3.4.0 and Python2.7

Any solution for this issue ?

@kahlju
Copy link

kahlju commented Mar 1, 2018

I have the same issue with that and I changed it to this: cv2.STEREO_BM_PREFILTER_NORMALIZED_RESPONSE
However, that isn't enough. This code has so many issues. I don't think I've seen anyone upload code that works from the getgo. I am now stuck with the line below that with cv2.Stereo_BM_fish_eye_Preset as that is completely useless. Who knows what this affects though. I would avoid using --useStereo_BM option though or you'll get the same error. I think the owner programmed around it. The 0.8 focal assumption is very bad that he uses. I was hoping to run this but I've had to do so many workarounds and I don't know how all the changes affect other untested functionality of the code.

Here is my latest error after that if you can figure it out:
From this:
colors = cv2.cvtColor(pair[0], 1)
Gives this error:
color.cpp:7341: error: (-215) scn == 3 || scn == 4 in function ipp_cvtColor

I've been told Douglas Gibbons code works from some reads but I've tried and come across very similar issues:

https://github.com/douglas-gibbons/StereoVision/tree/master/stereovision

Maybe I have helped you, maybe not. Someone really needs to pull this back to a known fully functional code for every program, version it and state tested version of opencv (I'm using opencv3.1 because I looked at version releases and saw that was the opencv 3 they should be talking about based on release dates when they updated it.

@aaronpaczak
Copy link

I just switched these to their respective integers, and it worked nicely:
https://docs.opencv.org/java/2.4.6/constant-values.html#org.opencv.calib3d.StereoBM.BASIC_PRESET

@erget
Copy link
Owner

erget commented Apr 10, 2018

Are you able to find these constants as defined in OpenCV? They should be in there somewhere as variables - using magic numbers makes me very nervous. If this is possible, I'd be happy to merge a pull request.

@sdlouhy
Copy link

sdlouhy commented May 25, 2018

Yes, all numbers are coming from official OpenCV documentation. Several of the function calls in blockmatcher have changed if you choose to update to CV 3.4.1 and python 3.5, however. On the bright side, it's not super difficult.

@sdlouhy
Copy link

sdlouhy commented May 25, 2018

As a followup to yesterday, when you switch to OpenCV 3.4.0+, you have to change some condition names in the _replace_bm function for both classes in the blockmatchers.py file, remove the first condition from the not SGBM class, and need to add _create (ex: cv2.StereoBM_create) to the end of the function call. [Link to StereoBM class] [Link to StereoSGBM class]

@SuperMisswei
Copy link

I have the same issue as the first one.But I don't know how to change it ,it's so many.need help.aaa

@GuillaumeDae
Copy link

Can you tell us how you change the blockmatchers.py file ? Please !
Where did you add _create ?
Thank you so much for your help

@sdlouhy
Copy link

sdlouhy commented Jan 19, 2019

@GuillaumeDae if you're lazy and don't want to find it, I have a updated version on my github here

@GuillaumeDae
Copy link

@sdlouhy Thank you it seems to work. I no longer have 'STEREO_BM_NARROW_PRESET' error.
The next problem is... permission denied while runing your code. (see images below)
Can you please help me with this ?
Maybe a simple step missing...
I am already very grateful !

error_permission_denied
line64

@sdlouhy
Copy link

sdlouhy commented Jan 20, 2019

@GuillaumeDae Do you have MeshLab installed? That's the only thing i can think of off the top of my head.

@erget
Copy link
Owner

erget commented Jan 29, 2019

@GuillaumeDae Looks to me like you don't have write permissions to the directory you're trying to write to.

@phebot
Copy link

phebot commented Mar 14, 2019

please find the path of cv.so ,and set the path into python env (/etc/.profile)
export PYTHONPATH="/usr/local/lib/python2.7/dist-packages:$PYTHONPATH"

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

8 participants