I just started using OpenCV 3.0 in python. I am trying one of the example "didgits.py" and I am getting the Attribute error:
Traceback (most recent call last):
File "C:\Users\Arpit Jindal\Desktop\opencv\sources\samples\python2\digits.py", line 171, in <module>
model = KNearest(k=4)
File "C:\Users\Arpit Jindal\Desktop\opencv\sources\samples\python2\digits.py", line 77, in __init__
self.model = cv2.KNearest()
AttributeError: 'module' object has no attribute 'KNearest'
Then I commented the code for KNearest and tried for SVM only and again I got the Attribute error:
Traceback (most recent call last):
File "C:\Users\Arpit Jindal\Desktop\opencv\sources\samples\python2\digits.py", line 177, in <module>
model = SVM(C=2.67, gamma=5.383)
File "C:\Users\Arpit Jindal\Desktop\opencv\sources\samples\python2\digits.py", line 89, in __init__
self.params = dict( kernel_type = cv2.SVM_RBF,
AttributeError: 'module' object has no attribute 'SVM_RBF'
I tried to search for these variable in OpenCV but couldn't find anything.
Are the python examples not updated? Where can I find the complete list of python API's and reference manual for OpenCV3.0 python, as the online docs is not complete for Machine Learning because I found many python API mentioned in 2.4.9 but not in 3.0?
Related
I'm trying a tutorial on Reinforcement learning wherein I'm currently trying to use gymnasium, mujoco, to train agents. I've installed mujoco and when I try to run the program, the sim window opens for a second and throws this error. Idk what I'm doing wrong.
import gymnasium as gym
import stable_baselines3
import imageio
env=gym.make('Humanoid-v4', render_mode='human')
obs=env.reset()
env.render()
print(obs)
BTW, I'm getting the output of print(obs) which returns a tensor. It's just the sim environment which is throwing this error.
Error Traceback
Traceback (most recent call last):
File "C:\Users\krish\anaconda3\envs\learn\lib\site-packages\gymnasium\envs\mujoco\mujoco_rendering.py", line 337, in __del__
File "C:\Users\krish\anaconda3\envs\learn\lib\site-packages\gymnasium\envs\mujoco\mujoco_rendering.py", line 330, in free
File "C:\Users\krish\anaconda3\envs\learn\lib\site-packages\glfw\__init__.py", line 2358, in get_current_context
AttributeError: 'NoneType' object has no attribute 'glfwGetCurrentContext'
C:\Users\KrunkCiti\AppData\Local\Programs\Python\Python310\Scripts>python OpenGLTensorGrowth.py
Traceback (most recent call last):
File "C:\Users\KrunkCiti\AppData\Local\Programs\Python\Python310\Scripts\OpenGLTensorGrowth.py", line 29, in
Dict = Canvas.winfo_pixels(info, 3840_2160),[Self.tk.getint]
File "C:\Users\KrunkCiti\AppData\Local\Programs\Python\Python310\lib\tkinter_init_.py", line 1163, in winfo_pixels
return self.tk.getint(
AttributeError: 'function' object has no attribute 'tk'
I'm pretty new to python and this code is for object detection, it works fine on my webcam but has an error when using an external camera
This is what I have:
for classId, confidence,box in zip(classIds.flatten(),confs.flatten(),bbox):
cv2.rectangle(img,box,color=(0,255,0),thickness=2)
cv2.putText(img,classNames[classId-1].upper(),(box[0]+10,box[1]+30),
cv2.FONT_HERSHEY_COMPLEX,1,(0,255,0),2)
Here's the message I got:
Traceback (most recent call last):
File "C:/Users/byeo9/PycharmProjects/FYP-ENV/Testing 2.py", line 31, in <module>
for classId, confidence,box in zip(classIds.flatten(),confs.flatten(),bbox):
AttributeError: 'tuple' object has no attribute 'flatten'
I am running a Python program in Raspberry Pi on startup (autostart) that I have placed in .bashrc but on startup, OpenCV code snippet contained file is not loading but normal Python program is running and I was using KNN(K Nearest Neighbour) on this algorithm I am getting the following error.
Traceback (most recent call last):
File "Desktop/carPlate/main.py", line 15, in <module>
import DetectChars
File "/home/pi/Desktop/carPlate/DetectChars.py", line 11, in <module>
kNearest = cv2.ml.KNearest_create()
AttributeError: 'module' object has no attribute 'ml'
I've just installed Gensim and have run a test. 484 tests run successfully however I hit an error:
======================================================================
ERROR: testAddMorphemesToEmbeddings (gensim.test.test_varembed_wrapper.TestVarembed)
Test add morphemes to Embeddings
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/franciskim/Downloads/gensim-2.0.0/gensim/test/test_varembed_wrapper.py", line 56, in testAddMorphemesToEmbeddings
vectors=varembed_model_vector_file, morfessor_model=varembed_model_morfessor_file)
File "/Users/franciskim/Downloads/gensim-2.0.0/gensim/models/wrappers/varembed.py", line 69, in load_varembed_format
morfessor_model = morfessor.MorfessorIO().read_binary_model_file(morfessor_model)
File "/Users/franciskim/anaconda/lib/python3.6/site-packages/morfessor/io.py", line 179, in read_binary_model_file
model = pickle.load(fobj)
AttributeError: Can't get attribute 'FixedCorpusWeight' on <module 'morfessor.baseline' from '/Users/franciskim/anaconda/lib/python3.6/site-packages/morfessor/baseline.py'>
----------------------------------------------------------------------
I can only find 1 other instance of this happening on the internet, but there are no answers to this yet.