Algomorph/pyboostcvconverter

import pbcvt failed

Closed this issue · 13 comments

hello Algomorph,at first thank you for making the pbcvt .
I can't use python.exe to import pbcvt after compiling a debug version.
error information:
image
My environment:
windows 10
python 3.9
msvc 2019(14.2)
boost 1.77:
b2 toolset=msvc-14.2 release debug runtime-link=shared link=static --with-python=python --abbreviate-paths architecture=x86 address-model=64 install -j4 --prefix="D:\Program Files (x86)\opencv\boost_1_77_0\ins"
Does the pbcvt support boost 1.77?
However, I found that there was no update for python module in boost 1.77.

"找不到指定的模块" means "can not find the specified module

I choose Debug version in MSVC2019,so I input the lib file : libboost_python39-vc142-mt-gd-x64-1_77.lib, is that OK?
I do not know why the INSTALL folder is empty,even if I have built the INSTALL project successfully in MSVC.
I found that when I choose Release version in MSVC, I can not compile the project successfully, maybe because of the debug version OpenCV.
And is there anything wrong with my cmake config?
image

I changed my OS into ubuntu18, but I still can not import pbvct.
Python 3.6.9 (default, Jan 26 2021, 15:33:00)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

import pbcvt
Traceback (most recent call last):
File "", line 1, in
ImportError: /usr/lib/python3/dist-packages/pbcvt.cpython-36m-x86_64-linux-gnu.so: undefined symbol: _ZNK5boost6python7objects21py_function_impl_base9max_arityEv
my cmake config on ubuntu
2021-08-26 18-02-03 的屏幕截图

@TudouJack, can you verify for me that you are using python3, not python when you try to import pbcvt in Ubuntu?

For the Windows build, since you're using the .lib Boost library version my guess is that it's not Boost, but rather OpenCV that is the culprit. Can you verify that the directory holding your opencv.dll and opencv_world.dll is added to your Path environment variable as I describe here?

For the Windows build, since you're using the .lib Boost library version my guess is that it's not Boost, but rather OpenCV that is the culprit. Can you verify that the directory holding your opencv.dll and opencv_world.dll is added to your Path environment variable as I describe here?

Thank you for your help.
However, I have checked the Path environment of my OS, I found the two paths which include opencv_world453d.dll have been added.
image

@TudouJack, can you verify for me that you are using python3, not python when you try to import pbcvt in Ubuntu?
I have commited my error information, you can see that Python 3.6.9 (default, Jan 26 2021, 15:33:00) [GCC 8.4.0] on linux
image

I used the dependency walker, I found that lots of x.dll are missing
image

I give up compile it on windows,and reset the python on ubuntu. I compile the project successfully,but a new error happened.
I add a new function in python_module.cpp,
PyObject* codec()
{
const std::string fname="rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov";
cv::Mat frame;
cv::cuda::GpuMat d_frame;
cv::Ptrcv::cudacodec::VideoReader d_reader = cv::cudacodec::createVideoReader(fname);
d_reader->nextFrame(d_frame);
d_frame.download(frame);
PyObject* result = pbcvt::fromMatToNDArray(frame);
return result;
}

and I have def("codec", codec); at last.
However,when I compiled it and try to import pbcvt, an error occurred

import pbcvt
Segmentation fault (core dumped)

Sorry to hear you're still having trouble. The Windows error looks indeed like something must be wrong with the OpenCV dependency tree, not pbcvt.

  1. Do I take it right that the vanilla pbcvt on ubuntu is built and imports without error? E.g. when you don't add your own code, can you import it and run the example functions fine?
  2. What happens when you don't use CUDA and use the regular, CPU-based video reader instead?

Sorry to hear you're still having trouble. The Windows error looks indeed like something must be wrong with the OpenCV dependency tree, not pbcvt.

  1. Do I take it right that the vanilla pbcvt on ubuntu is built and imports without error? E.g. when you don't add your own code, can you import it and run the example functions fine?
  2. What happens when you don't use CUDA and use the regular, CPU-based video reader instead?

Thank you for your help again, I have import pbcvt successfully without my own function.
I found that when I delete this line:
cv::Ptrcv::cudacodec::VideoReader d_reader = cv::cudacodec::createVideoReader(fname);
I can import pbcvt successfully.

And I changed my codec function into CPU-based video reader (video capture), I still can not import pbcvt with the same error .

import pbcvt
Segmentation fault (core dumped)

I give up compile it on windows,and reset the python on ubuntu. I compile the project successfully,but a new error happened.
I add a new function in python_module.cpp,
PyObject* codec()
{
const std::string fname="rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov";
cv::Mat frame;
cv::cuda::GpuMat d_frame;
cv::Ptrcv::cudacodec::VideoReader d_reader = cv::cudacodec::createVideoReader(fname);
d_reader->nextFrame(d_frame);
d_frame.download(frame);
PyObject* result = pbcvt::fromMatToNDArray(frame);
return result;
}

and I have def("codec", codec); at last.
However,when I compiled it and try to import pbcvt, an error occurred

import pbcvt
Segmentation fault (core dumped)

Modify CMakeLists.txt
#=============== Find Packages ====================================
#OpenCV
#find_package(OpenCV COMPONENTS core REQUIRED) # error
find_package(OpenCV REQUIRED) # pass

@TudouJack We need to preserve topicality here. There are three separate issues discussed in this thread:

  1. Compilation/installation issue on Windows
  2. Compilation/installation issue on Ubuntu
  3. Segfault on usage of cv::Ptrcv::cudacodec::VideoReader inside a custom function

I'm going to close this issue at this point, but please open separate issues here for each one that's still giving you trouble.

Aside from this, I observe that:
(1) or (2) look like marginal, system-specific issues (since the appveyor CI tests for both of these platforms succeed.)
(3) sounds like more of an issue with your code (how you're trying to use OpenCV elements within your C++-based python module) than pbcvt itself. That is, in the new issue, can you tell us (a) if you don't use any pbcvt C++ or CMake code, do you still get the error when you try to use VideoReader? And (b) did the suggestion from @Kisshine007 help?