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

This code would require porting to opencv4 #7

Open
hyunlee1o opened this issue Oct 23, 2019 · 12 comments
Open

This code would require porting to opencv4 #7

hyunlee1o opened this issue Oct 23, 2019 · 12 comments

Comments

@hyunlee1o
Copy link

A lot of the changes are easy to make but others are not that easy.
Could you look into that?

@lejeunel
Copy link

I started this port to opencv4. It comes with a boost-python wrapper.

https://github.com/lejeunel/gPb-GSoC

Keep in mind though that it produces malloc/seg-fault errors... which I'm still trying to solve.

@hyunlee1o
Copy link
Author

I can try to help, the main issues are found in the watershed file.
Because it need some refactoring to some malloc yes.

@lejeunel
Copy link

The watershed is ok for me.
The malloc issue seems to be in function contour_side. I'll let you know.

@hyunlee1o
Copy link
Author

Also i got errors compiling numpy-opencv-converter

Could NOT find PythonLibs: Found unsuitable version "2.7.16", but required
  is at least "3" (found /usr/lib/x86_64-linux-gnu/libpython2.7.so)

@lejeunel
Copy link

Two options:

  • Add a cmake flag to omit the python wrapper
  • Install python and boost

@hyunlee1o
Copy link
Author

I used this command

cmake .. -D CMAKE_BUILD_TYPE=RELEASE \
    -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.7m.so \
    -DPYTHON_INCLUDE_DIR=/usr/include/python3.7/ \
    -DPYTHON_EXECUTABLE=/usr/bin/python3.7

I had python and boost installed but it didn't work properly because of the numpy-opencv-converter CMakeLists.txt

Now it compiled without error.
Also mind to add the
cmake_minimum_required(VERSION 3.13)
To your CMakeLists.txt because it pops an error.

@lejeunel
Copy link

I'm not sure if I actually found the actual seg-fault culprit, but I got around it with shared pointers :x
See my last commit and let me know.

@hyunlee1o
Copy link
Author

eh, well, first i need to know how to use it X)
I did a pull.

@hyunlee1o
Copy link
Author

hyunlee1o commented Oct 28, 2019

Ok, it works but it's very slow wow.

PYTHON TYPE CONVERTERS exported
size(in1): [640 x 512]
size(in2): [640 x 512]
mPb computation commencing ...
 --->  computing texton ...
 --->  computing bg cga cgb tg ...
sPb computation commencing ...
gPb computation commencing ...
`fish: Job 2, 'python3  $argv' terminated by signal SIGSEGV (Address boundary error)`

I have seen it fails when i use a starred operation. I can only use it one by one.

@hyunlee1o
Copy link
Author

Also it's SUPER slow because EVERY SINGLE pixel access is made with img.at instead of a pointer.

@lejeunel
Copy link

lejeunel commented Oct 28, 2019

indeed this code is pretty bad.
Regarding crashes: It seems that there's a size limit to images. For now, I resize them to 300x300 and resize as post-processing.
Regarding performance: Are you willing to make a PR?

Here a reference for iterating on pixels:
https://docs.opencv.org/master/d3/d63/classcv_1_1Mat.html#a952ef1a85d70a510240cb645a90efc0d

@hyunlee1o
Copy link
Author

hyunlee1o commented Oct 28, 2019

I have done some work with opencv C++ int the past but a reminder is a pretty good option, also that im working rn 100% in python.

Also i get random crashes.
I am trying with images 640 x 512 and i got crashes in 2 out of 10.

I will review the package and maybe i will do some PR

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