As I try to catch convexity defects in an image with opencv+python, but "python said":
defects = cv2.convexityDefects(cnt,hull)
AttributeError: 'module' object has no attribute 'convexityDefects'
The python script was running under ubuntu 12.04+python 2.7+opencv from repository.
The code was modified from http://opencvpython.blogspot.fr/2012/06/contours-4-ultimate.html
thanks for your help
jean-pat
Related
Environment:-
OS : Ubuntu20.04
Python:2.7.18
Problem:-
I have gerrit trigger plugin installed in jenkins., while building my patch-set it always fails with below error
gbp parse spec failed. 'module' object has no attribute 'parse_spec'
I have already installed git-buildpackage-rpm package still getting the same error.
I have this python code when I run it ,it say
AttributeError: module 'cupy' has no attribute 'cupyx'
code:
# upload matrix and inverse diagonal GPU
A = cp.cupyx.scipy.sparse.csr_matrix(A)
I've installed cupy successfully in docker using
pip install cupy-cuda100
any help will be appreciated, thx
See the discussion in https://github.com/cupy/cupy/issues/2654 and try the following
import cupyx.scipy.sparse
cupyx.scipy.sparse.csr_matrix(A)
The alias cupy.cupyx was unintentionally there in some prereleases, but it has been removed because it is too confusing.
I am trying to connect to the shopify api but am having difficulty connecting when using Eclipse+PyDev. When connection via python in a bash shell the same commands work OK
to install:
pip3 install --upgrade ShopifyAPI
shopify.py (my code)
import shopify
shop_url = "https://APIKEY:PASSWORD#mystore.myshopify.com/admin/products.json
shopify.ShopifyResource.set_site(shop_url)
The reference to shopify.ShopifyResouce.. throws the following in PyDev:
AttributeError: 'module' object has no attribute 'ShopifyResource'
I think it may be due to relative imports in the shopify module (the same code works fine in a terminal).
In shopify.py: (shopify API)
from shopify.resources import *
in shopify.resources: (shopify API)
from ..base import ShopifyResource
When I run
from shopify.base import ShopifyResource
ShopifyResource.set_site(shop_url)
I get ImportError: No module named 'shopify.base'; 'shopify' is not a package
Any ides how I can fix this?
The problem might be you created a shopify.py file in your IDE rename that file and that error will be solved
I'm playing with openCV in python. I'd like to use the eigenface algorithm to guess who's in a picture.
I tried with
recognizer = cv2.createEigenFaceRecognizer()
and it complains that
'module' object has no attribute 'createEigenFaceRecognizer'
I read around in the internet and found that the submodule 'face' should be used starting form openCV 3, but as I run
recognizer = cv2.face.createEigenFaceRecognizer()
it complains with a
'module' object has no attribute 'face'
I'm puzzled..
Thanks
AC
edit - how I installed it:
1. download openCV from http://sourceforge.net/projects/opencvlibrary
2. unpack to ~/opencv
3. download opencv_contrib from https://github.com/Itseez/opencv_contrib
4. unpack to ~/opencv/contrib
5. >cd ~/opencv
6. >mkdir tmp; cd tmp
7. >cmake -D -DOPENCV_EXTRA_MODULES_PATH=~/opencv/contrib/modules CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ~/opencv
8. >make -j5
9. >sudo make install
You might need to rebuild opencv together with extra modules as described here - opencv_contrib, if you didn't do it yet.
cmake -D -DOPENCV_EXTRA_MODULES_PATH
that "-D" is the cause of the error
import cv2
fgbg = cv2.createBackgroundSubtractorMOG()
fgbg1 = cv2.createBackgroundSubtractorGMG()
AttributeError: 'module' object has no attribute 'createBackgroundSubtractorMOG()'
AttributeError: 'module' object has no attribute 'createBackgroundSubtractorMOG()'
Enviroment:
x64 win7
win32 python 2.7.3
opencv 3.0.0-beta
What should I do?
You may be interested in BackgroundSubtractorMOG2, which, although not documented, has a python binding in opencv 3.0.0-beta.
import cv2
fgbg = cv2.createBackgroundSubtractorMOG2(detectShadows=True)
both were moved in 3.0 to the opencv_contrib repo
you will need to build it along with your main opencv repo using cmake. (no prebuild versions of this available) then running the INSTALL project (or make install) will copy your new cv2.pyd to the python folder.
then:
>>> import cv2
>>> cv2.bgsegm.createBackgroundSubtractorMOG # note additional bgsegm namespace !
<built-in function createBackgroundSubtractorMOG>
Use cv2.BackgroundSubtractorMOG()
because cv2.createBackgroundSubtractorMOG2 was replaced in the latest versions of opencv.
Try one of the following solutions:
cv2.bgsegm.createBackgroundSubtractorMOG()
or:
cv2.bgsegm.createBackgroundSubtractorMOG2()