I have compiled the aruco library as stated here github link for aurco library
I have checked it has compiled successfully as i can import it in python without any error and to check i have run the example.py script also it's working but when i wrote this code
import cv2
import numpy as np
import aruco
Dictionary = aruco.getPredefinedDictionary(aruco.PREDEFINED_DICTIONARY_NAME(DICT_5X5_250=6))
aruco.drawMarker(Dictionary,5,250,markerImage,1)
aruco.drawMarker(Dictionary,10,250,markerImage,1)
aruco.drawMarker(Dictionary,20,250,markerImage,1)
aruco.drawMarker(Dictionary,25,250,markerImage,1)
aruco.drawMarker(Dictionary,50,250,markerImage,1)
aruco.drawMarker(Dictionary,100,250,markerImage,1)
aruco.drawMarker(Dictionary,200,250,markerImage,1)
cv2.imshow("markers",markerImage)
cv2.waitKey(0)
cv2.imgwrite(marker.jpg,markerImage)
it throws error
Traceback (most recent call last): File "drawmarker.py", line 7, in
Dictionary = aruco.getPredefinedDictionary(aruco.PREDEFINED_DICTIONARY_NAME(DICT_5X5_250=6))
AttributeError: 'module' object has no attribute
'getPredefinedDictionary'
can someone please let me know what am i doing wrong, is this module not imported in python version of aruco ?
maybe you should try this "aruco.DICT_5X5_250" as parameter, like...
dict = aruco.getPredefinedDictionary( aruco.DICT_5X5_250 )
it worked for me :)
Related
I have made a module:
However I got this error when I import the count_kmers function:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'kmer_cython' has no attribute 'count_kmers'
I import my stuff like this:
from Seq_utils.fasta_parser import parse_fasta
from kmer_cython import count_kmers
from Alphabet.alphabet import iupac_dna
My function was defined like this:
It is a simple function that worked fine when I had it spread in the middle of other functions in my directory. Then I decide to organize it and now I wish to run it, but I can't.
I have set the PYTHONPATH in my terminal and other codes that I made a module are working.
Any tip to solve this problem?
Thank you all for your time.
Paulo
I'm new to python and I'm currently learning objects and graphics. I imported the graphics.py file successfully but for some reason it keeps giving me an attribute error whenever I try to run GraphWin. please see below:
import graphics
win = graphics.GraphWin()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'graphics' has no attribute 'GraphWin'
I'm using Zelle's "Python Programming: An Introduction to Computer Science" and it's been helpful.
please advise.
Is the graphics.py in the same as the file you’re getting the error in?
Also, try
from graphics import *
Instead of
import graphics
i checked out this article and it proved helpful. i just had to create an extension where i added the specific sub-module to the module folder. in this case it's:
from graphics._init_ import *
win = GraphWin()
this solves the attribute error. however, it only works with the from import * formula and not the import formula
This is my first time asking a question so please excuse me.
I am following a tutorial and using the code in this folder: https://github.com/ehmatthes/pcc_2e/tree/master/chapter_12/adding_ship_image
I literally replicated this folder in vs code with all the code and the names being used correctly.
For some reason I am getting this error:
Traceback (most recent call last):
File "/Users/sammyawad/Documents/projects/alieninvasion/alien_invasion.py", line 6, in <module>
from ship import Ship
ImportError: cannot import name 'Ship' from 'ship' (/Users/sammyawad/Documents/projects/alieninvasion/ship.py)
Also, I think I have an issue with linting because it is highlighting the pygame init functions for the class even though it works.
Change it to:
from .ship import Ship
import module as instance of class like this...
from ship import Ship as s1
I'm trying to convert Keras to a Core ML model but I'm stuck when converting the Python file into a mlmodel.
I'm getting errors when importing submodules of 'coremltools'.
The error that I'm getting is: "python recog.py
Traceback (most recent call last):
File "recog.py", line 3, in
from coremltools import convert
ImportError: cannot import name 'convert'
"
I tried to import the submodules in a different way but nothing worked for me.
I hope anyone can help me!
You can see the Python code, in the sample below:
import coremltools
from coremltools import converters
from coremltools import convert
coreml_model = coremltools.converters.keras.convert('model.h5', input_names='data', image_input_names='data', is_bgr=True, output_names='species')
coreml_model.save('model.mlmodel')
Make sure the name you are trying to import is in the module coremltools.
In the file, coremtools.py double check if the name is same I.e. convert.
Check the location of the coremtools.py file, is it in the main folder of python where python.exe exists?
The following code does not work. It seems that the R warning message raises a python error.
# enable use of python objects in rpy2
import rpy2.robjects.numpy2ri
import numpy as np
from rpy2.robjects import r
# create an example array
a = np.array([[5,2,5],[3,7,8]])
# this line leads to a warning message, which in turn raises an
# error message if run within a script.
result = r['chisq.test'](a)
Running that code example in ipython works, however, running it inside a script raises the errorTypeError: 'module' object is unsubscriptable. I assume this is due to the warning message.
What is the best way to avoid this problem?
Thanks in advance!
Put a print statement right before the error:
print(r)
result = r['chisq.test'](a)
The error message TypeError: 'module' object is unsubscriptable is claiming that r is referencing a module. When you run the script with the print statement, you'll see something like
<module 'rpy2' from '/usr/lib/python2.6/dist-packages/rpy2/__init__.pyc'>
Traceback (most recent call last):
File "/home/unutbu/pybin/test.py", line 14, in <module>
result = r['chisq.test'](a)
TypeError: 'module' object is unsubscriptable
Note that the first line says that r is referencing the module rpy2.
This should give you a clue as to what is going wrong. Once you find the name of the trouble-making module, check your import statements to see how r is getting reassigned to that module.
For example, if you have
from rpy2.robjects import r
...
import rpy2 as r
then the second import statement is overriding the first, and the name r is thereafter referencing the module rpy2 instead of rpy2.robjects.r.