Ask Your Question
0

How to use MOG in python openCV 3.2.0 version [closed]

asked 2017-03-24 11:43:35 -0600

picaso gravatar image

updated 2017-03-25 03:49:08 -0600

Traceback (most recent call last):
  File "ex1.py", line 6, in <module>
    fgbg = cv2.bgsegm.createBackgroundSubtractorMOG()
AttributeError: 'module' object has no attribute 'bgsegm'

I even build the opencv_contrib files as well. but still when i type

python
import cv2
help(cv2)

the bgsegm module not seems to be there. cmake output

-- Detected version of GNU GCC: 54 (504)
-- FP16: Feature disabled
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found suitable version "1.2.8", minimum required is "1.2.3") 
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.8") 
-- Found OpenEXR: /usr/lib/x86_64-linux-gnu/libIlmImf.so
-- Checking for module 'gstreamer-base-1.0'
--   No package 'gstreamer-base-1.0' found
-- Checking for module 'gstreamer-video-1.0'
--   No package 'gstreamer-video-1.0' found
-- Checking for module 'gstreamer-app-1.0'
--   No package 'gstreamer-app-1.0' found
-- Checking for module 'gstreamer-riff-1.0'
--   No package 'gstreamer-riff-1.0' found
-- Checking for module 'gstreamer-pbutils-1.0'
--   No package 'gstreamer-pbutils-1.0' found
-- Looking for linux/videodev.h
-- Looking for linux/videodev.h - not found
-- Looking for linux/videodev2.h
-- Looking for linux/videodev2.h - found
-- Looking for sys/videoio.h
-- Looking for sys/videoio.h - not found
-- Checking for module 'libavresample'
--   No package 'libavresample' found
-- Checking for module 'libgphoto2'
--   No package 'libgphoto2' found
-- Found TBB: /usr/lib/x86_64-linux-gnu/libtbb.so
-- found IPP (ICV version): 9.0.1 [9.0.1]
-- at: /home/ruwiniopatha/OpenCV/build/3rdparty/ippicv/ippicv_lnx
-- Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
-- Could NOT find Atlas (missing:  Atlas_CLAPACK_INCLUDE_DIR) 
-- Found apache ant 1.9.6: /usr/bin/ant
-- Could NOT find Matlab (missing:  MATLAB_MEX_SCRIPT MATLAB_INCLUDE_DIRS MATLAB_ROOT_DIR MATLAB_LIBRARIES MATLAB_LIBRARY_DIRS MATLAB_MEXEXT MATLAB_ARCH MATLAB_BIN) 
-- The imported target "vtkRenderingPythonTkWidgets" references the file
   "/usr/lib/x86_64-linux-gnu/libvtkRenderingPythonTkWidgets.so"
but this file does not exist.  Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
   "/usr/lib/cmake/vtk-6.2/VTKTargets.cmake"
but not all the files it references.

-- The imported target "vtk" references the file
   "/usr/bin/vtk"
but this file does not exist.  Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
   "/usr/lib/cmake/vtk-6.2/VTKTargets.cmake"
but not all the files it references.

-- Found VTK ver. 6.2.0 (usefile: /usr/lib/cmake/vtk-6.2/UseVTK.cmake)
-- Caffe:   NO
-- Protobuf:   YES
-- Glog:   YES
-- Looking for tiny_dnn.h
-- Looking for tiny_dnn.h - found
-- Found tiny-dnn in: /usr/local/include
-- C++11 support has been enabled by default.
-- freetype2:   YES
-- harfbuzz:    YES
-- No preference for use of exported gflags CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported gflags CMake configuration if available.
-- Found installed version of gflags: /usr/local/lib/cmake/gflags
-- Detected gflags version: 2.2.0
-- Checking SFM deps... TRUE
-- CERES support is disabled. Ceres Solver for reconstruction API is required.
-- freetype2:   YES
-- harfbuzz:    YES
-- Looking for tiny_dnn.h
-- Looking for tiny_dnn.h ...
(more)
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by berak
close date 2017-03-26 02:29:33.155397

2 answers

Sort by ยป oldest newest most voted
0

answered 2017-03-24 16:01:21 -0600

berak gravatar image

updated 2017-03-24 16:05:55 -0600

no such thing as 3.2.1

and you'll need to rebuild with opencv_contrib

edit flag offensive delete link more

Comments

sorry it should be 3.2.0 I did download the opencv_contrib, and build the package using cmake even. But the result is same... Any idea...

picaso gravatar imagepicaso ( 2017-03-24 23:42:47 -0600 )edit

possible reasons:

  • you're still using the old cv2.pyd (check cv2.__version__)
  • bgsegm module was not selected, when running cmake
  • cv2.pyd was not built, or there was a build fail while running make

again, we cannot help you without more detailled information.

berak gravatar imageberak ( 2017-03-25 02:42:22 -0600 )edit

@berak when i check the cv2.__version__ it returned 3.2.0

and the cmake code was

 cmake -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules -DBUILD_opencv_legacy=OFF -DBUILD_opencv_saliency=OFF -DBUILD_opencv_bgsegm=ON -DBUILD_opencv_line_descriptor=OFF -DWITH_QT=ON ../../OpenCV
picaso gravatar imagepicaso ( 2017-03-25 03:32:59 -0600 )edit

let's look at the cmake output ! (add it to your question (it's rather long))

berak gravatar imageberak ( 2017-03-25 03:36:39 -0600 )edit
1

@berak I have included that output inside the question...hope it would help..thanks in advance

picaso gravatar imagepicaso ( 2017-03-25 03:51:52 -0600 )edit

"To be built: " section there has bgsegm, python2 python3, so no visible problem in that step (unfortunately..)

berak gravatar imageberak ( 2017-03-25 04:06:16 -0600 )edit

thats what i am worried about.... it says bgsegm is in to be build section even.. isthere a way to uninstall opencv fully

picaso gravatar imagepicaso ( 2017-03-25 22:28:35 -0600 )edit

make clean will remove your current build

(but i'm still thinking, you have a previous one, also 2 python versions, and somehow you get the wrong one, when you try to run a script)

berak gravatar imageberak ( 2017-03-25 22:40:08 -0600 )edit

i removed all the opencv packages.. and started installing them from the scratch....lets see..By the way thanks for advices.. means alot..

picaso gravatar imagepicaso ( 2017-03-25 23:22:17 -0600 )edit
0

answered 2017-03-26 00:34:46 -0600

picaso gravatar image

The question was solved. When downloading opencv_contrib the previous version have being downloaded in a partial manner.... With the full version it can build successfully...

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-03-24 11:43:35 -0600

Seen: 832 times

Last updated: Mar 25 '17