sagi-z / BackgroundSubtractorCNT

A very fast background subtraction implementation for OpenCV 3.1.0 and above
Other
117 stars 28 forks source link

error in python demo #11

Closed arasharchor closed 6 years ago

arasharchor commented 6 years ago

I have installed the library without a problem. However, I am receiving the following error when running demo.py file.


(cv-py3) majid@majid:~/BackgroundSubtractorCNT/build$ cmake -DBUILD_TEST=ON -DBUILD_SHARED_LIBS=ON -DPYTHON_EXTENSION=ON -DCMAKE_BUILD_TYPE=DEBUG ..
OpenCV_LIB_DIR is: 
OpenCV_LIBS_NATIVE is: 'opencv_flann','opencv_videostab','opencv_highgui','opencv_objdetect','opencv_core','opencv_superres','opencv_imgcodecs','opencv_photo','opencv_imgproc','opencv_features2d','opencv_video','opencv_ml','opencv_stitching','opencv_calib3d','opencv_videoio','opencv_dnn','opencv_shape','opencv_text','opencv_fuzzy','opencv_phase_unwrapping','opencv_bgsegm','opencv_plot','opencv_rgbd','opencv_freetype','opencv_surface_matching','opencv_saliency','opencv_face','opencv_sfm','opencv_hfs','opencv_bioinspired','opencv_hdf','opencv_datasets','opencv_xphoto','opencv_line_descriptor','opencv_dnn_objdetect','opencv_optflow','opencv_reg','opencv_structured_light','opencv_dpm','opencv_tracking','opencv_aruco','opencv_ximgproc','opencv_cvv','opencv_stereo','opencv_ccalib','opencv_xobjdetect','opencv_img_hash','opencv_xfeatures2d'
OpenCV_LIB_DIR_NATIVE is: 
OpenCV_INCLUDE_DIRS_NATIVE is: '/usr/local/include','/usr/local/include/opencv'
CMAKE_CURRENT_SOURCE_DIR_NATIVE is: /home/majid/BackgroundSubtractorCNT/python
BGSUBCNT_INCLUDE_DIR_NATIVE is: /home/majid/BackgroundSubtractorCNT
Detected working in virtualenv '/home/majid/.virtualenvs/cv-py3'
PYTHON_SITE_DIR is '/home/majid/.virtualenvs/cv-py3/lib/python2.7/site-packages'
-- Configuring done
-- Generating done
-- Build files have been written to: /home/majid/BackgroundSubtractorCNT/build
(cv-py3) majid@majid:~/BackgroundSubtractorCNT/build$ make
[ 40%] Built target bgsubcnt
[ 80%] Built target demo
[100%] Generating build/timestamp
running install
running build
running build_py
running build_ext
running install_lib
running install_egg_info
Removing ./lib/python/bgsubcnt-1.1.3.egg-info
Writing ./lib/python/bgsubcnt-1.1.3.egg-info
[100%] Built target bgsubcnt_python
(cv-py3) majid@majid:~/BackgroundSubtractorCNT/build$ cd ..
(cv-py3) majid@majid:~/BackgroundSubtractorCNT$ python python/demo.py -file=/home/majid/videos/videos_in/19404260.mp4 -type="CNT"
Traceback (most recent call last):
  File "/home/majid/BackgroundSubtractorCNT/python/bgsubcnt.py", line 18, in swig_import_helper
    fp, pathname, description = imp.find_module('_bgsubcnt', [dirname(__file__)])
  File "/home/majid/.virtualenvs/cv-py3/lib/python3.5/imp.py", line 296, in find_module
    raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_bgsubcnt'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "python/demo.py", line 6, in <module>
    import bgsubcnt
  File "/home/majid/BackgroundSubtractorCNT/python/bgsubcnt.py", line 28, in <module>
    _bgsubcnt = swig_import_helper()
  File "/home/majid/BackgroundSubtractorCNT/python/bgsubcnt.py", line 20, in swig_import_helper
    import _bgsubcnt
ImportError: No module named '_bgsubcnt'
`
sagi-z commented 6 years ago

I see you are working with virtualenv, so you are not making a system wide installation. To install only on your virtualenv (assuming you have the numpy and cv2 modules there) do this from the build directory: python python/setup.py install

arasharchor commented 6 years ago

Okay got it. thanks

Hameednsn commented 4 years ago

I am also getting the above same issue, when I try to execute python setup.py install from path where python.exe is present, but I am getting error saying: setup.py not found , when I searched I found there are many setup.py file present in Numpy and its sub directories, don't know which setup.py I need to execute, can you please help. thanks in adv

sagi-z commented 4 years ago

The setup.py is in a sub directory: python python/setup.py install

Hameednsn commented 4 years ago

Thanks Sagi for quick response, really appreciate, I do not have python directory, my python.exe is present at: C:\Users\hamee\PycharmProjects\test2\Scripts , here test2 is my python3.6 env. I am using Windows 10, installed Pycharm latest version. I am using python 3.6 version.

sagi-z commented 4 years ago

If u want to install from this repository then u can follow https://sagi-z.github.io/BackgroundSubtractorCNT/start/ However, since this is part of opencv now, I recommend u try a recent tutorial on using python with opencv.

Hameednsn commented 4 years ago

OK, thank you for your prompt reply. I will try steps from link.

On Sun, Jan 5, 2020 at 7:59 PM Sagi Zeevi notifications@github.com wrote:

If u want to install from this repository then u can follow https://sagi-z.github.io/BackgroundSubtractorCNT/start/ However, since this is part of opencv now, I recommend u try a recent tutorial on using python with opencv.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sagi-z/BackgroundSubtractorCNT/issues/11?email_source=notifications&email_token=AIHWYMJD7HWR5CE5J6SDDV3Q4HVGFA5CNFSM4ESJYOT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIDYEZQ#issuecomment-570917478, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIHWYMP6ANLL4UEY33LJ6LTQ4HVGFANCNFSM4ESJYOTQ .