StereoVision icon indicating copy to clipboard operation
StereoVision copied to clipboard

Unable to run tune_blockmatcher and image_to_pointcloud

Open praneethshub opened this issue 7 years ago • 12 comments

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 ?

praneethshub avatar Feb 21 '18 22:02 praneethshub

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.

kahlju avatar Mar 01 '18 21:03 kahlju

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

aaronpaczak avatar Apr 07 '18 21:04 aaronpaczak

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.

erget avatar Apr 10 '18 08:04 erget

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 avatar May 25 '18 04:05 sdlouhy

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]

sdlouhy avatar May 25 '18 18:05 sdlouhy

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

SuperMisswei avatar Sep 07 '18 06:09 SuperMisswei

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

GuillaumeDae avatar Jan 19 '19 13:01 GuillaumeDae

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

sdlouhy avatar Jan 19 '19 21:01 sdlouhy

@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

GuillaumeDae avatar Jan 19 '19 23:01 GuillaumeDae

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

sdlouhy avatar Jan 20 '19 22:01 sdlouhy

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

erget avatar Jan 29 '19 08:01 erget

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"

phebot avatar Mar 14 '19 08:03 phebot