andrewssobral / bgslibrary

A C++ Background Subtraction Library with wrappers for Python, MATLAB, Java and GUI on QT
MIT License
2.19k stars 740 forks source link

Provide a .pyd file for users #160

Open laokangde opened 5 years ago

laokangde commented 5 years ago

I try to install this lib from 9:00am to 8:00pm and finally I made it. Here is what I got - a pybgs.pyd file, it works well with python3.7, hope that it may help you. pybgs.txt Remember to change the file from .txt to .pyd before you use it.

andrewssobral commented 5 years ago

Hi @laokangde , Thanks a lot for your contribution. Can you explain me the steps you did to build the pybgs.pyd file ? This was done using the latest master branch? I am still working to publish a stable and working version of pybgs in the PyPi repository. New improvements are also coming. Thanks in advance

laokangde commented 5 years ago

Thank you for your contribution. Here is my environment:

WIN10 version=1903 Anaconda python=3.7.3 VisualStudio_enterprise_2015 OpenCv=3.47 cmake=3.15.2

I follow those steps:https://github.com/andrewssobral/bgslibrary/wiki/Wrapper:-Python#building-bgslibrary-with-python-support-on-windows. There are some ‘PATH’ problems occured, so I add 'C:\Program Files\opencv\build\x64\vc14\bin' and 'C:\Program Files\bgslibrary-master\build' to my system environment (better to reboot system) .

I failed with https://github.com/andrewssobral/bgslibrary/wiki/Wrapper:-Python#building-with-anaconda-python, the error is when I input make -j8 , it says 'no target' , I installed 'MinGW' by the way.

I faild with MATLAB2018bhttps://github.com/andrewssobral/bgslibrary/tree/master/wrapper/matlab. I changed ‘compile.m’ 40:41 from "../../src/algorithms/T2F/FuzzyUtils.cpp" ... to "../../src/tools/FuzzyUtils.cpp" ... due to the 'path' error. After that I stopped by the error :

error mexOpenCV (line 136) C:\Program Files\MATLAB\R2018b\toolbox\bgslibrary-master\src\algorithms\DPTexture.cpp: In member function 'virtual void bgslibrary::algorithms::DPTexture::process(const cv::Mat&, cv::Mat&, cv::Mat&)': C:\Program Files\MATLAB\R2018b\toolbox\bgslibrary-master\src\algorithms\DPTexture.cpp:33:35: error: taking address of temporary [-fpermissive] frame = cvCloneImage(&(IplImage)img_input); ^~~~~

andrewssobral commented 5 years ago

Great, thank you @laokangde for reporting these issues, I've just fixed now. Can you try the latest master branch? Please let me know if it works well for you. Best regards.

I changed ‘compile.m’ 40:41 from "../../src/algorithms/T2F/FuzzyUtils.cpp" ... to "../../src/tools/FuzzyUtils.cpp" ... Fixed.

error mexOpenCV (line 136) C:\Program Files\MATLAB\R2018b\toolbox\bgslibrary-master\src\algorithms\DPTexture.cpp: In member function 'virtual void bgslibrary::algorithms::DPTexture::process(const cv::Mat&, cv::Mat&, cv::Mat&)': C:\Program Files\MATLAB\R2018b\toolbox\bgslibrary-master\src\algorithms\DPTexture.cpp:33:35: error: taking address of temporary [-fpermissive] frame = cvCloneImage(&(IplImage)img_input); ^~~~~ Fixed

laokangde commented 5 years ago

Thanks, but still failed with MATLAB2018b.

First, I copy those C:\Program Files\opencv\build\include\opencv2 to C:\Program Files\MATLAB\R2018b\toolbox\bgslibrary-master\src\algorithms\opencv2 because it says :

In file included from C:\Program Files\MATLAB\R2018b\toolbox\bgslibrary-master\wrapper\matlab\backgroundSubtractor_wrapper.cpp:8:0: ....\src\algorithms/IBGS.h:16:39: fatal error: opencv2/highgui/highgui_c.h: No such file or directory

include <opencv2/highgui/highgui_c.h>

^ compilation terminated.

Then a long error occured : error.txt

andrewssobral commented 5 years ago

Humm...I think this is related to the installation of the OpenCV on MATLAB. You don't need to put opencv2 folder inside src\algorithms. In this case you should install the package opencvinterface.mlpkginstall provided in the matlab wrapper folder before compiling the bgslibrary. It will install the OpenCV 3.4.1 and the related Mex files. Here's a small guidance:

* First install [Computer Vision System Toolbox OpenCV Interface]
* * Go to: bgslibrary/wrapper_matlab
* * Double-click on [opencvinterface.mlpkginstall] inside your MATLAB.
-- wait installation, it takes a few minutes ---

* Run: compile.m

* Run demo: demo.m
laokangde commented 5 years ago

Unfortunately, I have installed [Computer Vision System Toolbox OpenCV Interface] already, if just install [Computer Vision System Toolbox OpenCV Interface] without putting opencv folder inside, here is the error you may get

In file included from C:\Program Files\MATLAB\R2019a\toolbox\bgslibrary-master\wrapper\matlab\backgroundSubtractor_wrapper.cpp:8:0: ....\src\algorithms/IBGS.h:16:39: fatal error: opencv2/highgui/highgui_c.h: No such file or directory

include <opencv2/highgui/highgui_c.h>

^ compilation terminated.

And, if I put the opencv folder inside, this No such file or directory error will disappear, the long error that I have uploaded last time will occur.