I am using cv2 version 4.0.0 and python version 3.7.2.
I am trying to subtract Background using this method cv2.createBackgroundSubtractorMOG2() and its working well.
But when I use cv2.createBackgroundSubtractorMOG() its not working its showing me
AttributeError: module 'cv2.cv2' has no attribute
'createBackgroundSubtractorMOG '.
I also tried cv2.BackgroundSubtractorMOG() but i got same error
AttributeError: module 'cv2.cv2' has no attribute
'BackgroundSubtractorMOG'.
and another subtraction method cv2.createBackgroundSubtractorGMG() also not working.
I also refer other stackoverflow answers but I didn't get solution.
MOG2 containts in main opencv repository. MOG and GMG are from opencv_contrib: https://github.com/opencv/opencv_contrib/tree/master/modules/bgsegm
there are two subtraction packages in opencv. BackgroundSubtractorMOG() it's at cv2.bgsegm.BackgroundSubtractorMOG(),to use you must install opencv-contrib-python
Related
I am trying to use the object detection tutorial from tensor flow api. I am using python 3 and tensor flow version 2. But getting the below error.I tried several ways:
File "C:\Aniruddhya\object_detection\object_detection\utils\label_map_util.py", line 137, in load_labelmap
with tf.gfile.GFile(path, 'r') as fid:
AttributeError: module 'tensorflow' has no attribute 'gfile'
can someone help me to run this?
code link: https://drive.google.com/drive/u/3/folders/1XHpnr5rsENzOOSzoWNTvRqhEbLKXaenL
It's not called that in TensorFlow 2. You might be using a TensorFlow 1 tutorial.
Version 1
tf.gfile.GFile
https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/io/gfile/GFile
Version 2
tf.io.gfile.GFile
https://www.tensorflow.org/api_docs/python/tf/io/gfile/GFile
If you have Tensorflow version 2. You can use the next module compatible with the version 1, too.
import tensorflow.compat.v1 as tf
I solved this problem by reinstalling tensor using the previous version: sudo pip3 install tensorflow==1.14.0
You may optionally downgrade to previous version of tensorflow:
!pip install tensorflow==1.12.0
import tensorflow as tf
print(tf.__version__)
otherwise , make if tf.io.gfile and import tf.io
I want to use dask.read_fwf(file), but I get there error
AttributeError: module 'dask' has no attribute 'read_fwf'
The same problem occurs for read_csv and read_table.
I have uninstalled and reinstalled dask, as well as trying to rename my 'csv.py' file in \dask\dataframe\io. The same problem occurs after both of these attempted fixes.
pd.read_fwf and the like work fine.
You wanted dask.dataframe.read_fwf
import dask.dataframe as dd
dd.read_fwf
I used different types of things and I need this to work in 3.6 Python. i also try
roc = cv2.face.LBPHFaceRecognizer_create() but getting the same error but this time with face module. Need help.
The same code is working in python 2.7.13, opencv 2.4.10.
How to make it work in python 3.6 and opencv 3.4.
I am working in a windows environment.
You likely have the opencv-python package installed instead of the opencv-contrib-python package. A lot of the proprietary algorithms were removed from the main OpenCV repository when OpenCV came out and put in the contrib repository.
Try switching versions.
Please I really need help with this error i keep getting. I have been find it difficult to make a plot with seaborn. Whenever i tried using the code i import seaborn as it gives me the same error as shown in the image link below. I have tried using conda install all over again but i keep getting the same error. Please what else can I do? Thank you
image
You probably have an older version of the seaborn. Try to reinstall using pip install seaborn --upgrade.
I want to use sift() in python &openCV
here is my environment:
python:2.7.6
os:ubuntu 14.04
opencv:2.4.9
After several hours hard-work, now i seem to successfully install opencv,because i can do as below:
import cv2
print cv2.version ---- 2.4.9
now my problem is that when i want to call cv2.sift(),it says AttributeError: 'module' object has no attribute 'sift'
If i download opencv_contrib from github and use cmake -DOPENCV_EXTRA_MODULES_PATH=/modules , the compiling will fail , it says:
Module opencv_xfeatures2d disabled because opencv_shape dependency can't be resolved!
someone else even says the opencv_contrib can only work with opencv3
then how can i solve this problem? I need your help~