ITCoders / Human-detection-and-Tracking

Human-detection-and-Tracking
Apache License 2.0
850 stars 307 forks source link

Incompatibility in Opencv3 and opencv_contrib #24

Closed ideaRunner closed 6 years ago

ideaRunner commented 6 years ago

Hi, ITCoders, I want to run this proj to watch the demo, but i found some incompatibilities in opencv3 As I have searched in google, I change two line of your code. But I still have an error with no idea.

At line 16, I changed it to recognizer = cv2.face.LBPHFaceRecognizer_create() At line 137, I changed it to recognizer.read("model.yaml")

but still have an error:

Traceback (most recent call last): File "main.py", line 137, in recognizer.read("model.yaml")

cv2.error: /home/ssss/opencv/opencv/modules/core/src/persistence.cpp:891: error: (-2) The node is neither a map nor an empty collection in function cvGetFileNodeByName

Can you give me some help ? Thanks !

prsntmaurya commented 6 years ago

Hi there, Can you please specify which OpenCV version you are using to run this code?

ideaRunner commented 6 years ago

Hi, My cv2.__version__ is 3.3.1-dev, build from opencv and opencv_contrib My python version is Python 3.5.2

prsntmaurya commented 6 years ago

Hi there, Is your problem solved? If not please check that you have integrated the contrib_modules while building the OpenCV. You can follow these commands in order to avoid above error:

wget https://bootstrap.pypa.io/get-pip.py

sudo python3 get-pip.py

sudo apt-get install build-essential

sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev

sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

Download and extract zip of OpenCV version 3.0 and above from Github

So you two folders named opencv and opencv_contrib and follow following steps:

cd opencv

mkdir build

cd build

cmake -D CMAKE_BUILD_TYPE=RELEASE -DOPENCV_EXTRA_MODULES_PATH=/home/prashant/opencv_contrib/modules -D CMAKE_INSTALL_PREFIX=/usr/local ..

make -j4

sudo make install

On 15 December 2017 at 12:20, BinZ notifications@github.com wrote:

Hi, My cv2.version is 3.3.1-dev, build from opencv https://github.com/opencv/opencv and [opencv_contrib] ( https://github.com/opencv/opencv_contrib) My python version is Python 3.5.2

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ITCoders/Human-detection-and-Tracking/issues/24#issuecomment-351928032, or mute the thread https://github.com/notifications/unsubscribe-auth/AKYNLliD6Lr-IxnKHJAiLm8pJ-zEeWwqks5tAhaugaJpZM4Q_93s .

ideaRunner commented 6 years ago

Hi prsntmaurya,

Thank you for your advice. I am sure have integrated the conrib_modules , because if not, I will get an error:

There is no module named face.

I have fellowed the guide from learnopencv site which I think have same steps as yours.

I think the problem is the opencv3_contrib library have changed, Like some function's name I mentioned before.

emm, I still can not solve this problem. Or do you have time to update it, so that it can be compatible with opencv3?

Thank you again for your patience and time.

prsntmaurya commented 6 years ago

Hi, I am currently using OpenCV version: '3.1.0-dev' with Python version 3.5.2 and I am not facing any such problem. So the code is compatible with OpenCV version 3.

On 25 December 2017 at 20:00, BinZ notifications@github.com wrote:

Hi prsntmaurya,

Thank you for your advice. I am sure have integrated the conrib_modules , because if not, I will get an error:

There is no module named face.

I have fellowed the guide from learnopencv site https://www.learnopencv.com/install-opencv3-on-ubuntu/ which I think have same steps as yours.

I think the problem is the opencv3_contrib library have changed, Like some function's name I mentioned before.

emm, I still can not solve this problem. Or do you have time to update it, so that it can be compatible with for opencv3?

Thank you again for your patience and time.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ITCoders/Human-detection-and-Tracking/issues/24#issuecomment-353872946, or mute the thread https://github.com/notifications/unsubscribe-auth/AKYNLgWWwQt5TWrNOshhaUP0BUAj6jOfks5tD7F_gaJpZM4Q_93s .

diaodiaozhuye commented 6 years ago

I also encountered this problem. I still can not solve this problem

prsntmaurya commented 6 years ago

Hi, I have seen the difference between the version of OpenCV 3.1 and OpenCV 3.3, it is clear there are several changes from opencv_contrib modules version 3.1 to version 3.3. That's why you are facing such problem. If you can switch to OpenCV version 3.1 then the error will be resolved or you can provide me the exact error details without changing any line in the code along with the OpenCV version(the above-mentioned error is after the change in code).

prsntmaurya commented 6 years ago

I am closing the issue now, I hope it is resolved.

prsntmaurya commented 6 years ago

This issue is solved in issue #25, please refer that.