Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
qrcode detector not in cv2
#1
I am just following the instructions here, trying to learn how this works.

I am now trying to read a qr code I made.

this shows no errors:

Quote:# read the QRCODE image
img1 = cv2.imread("myQR_blue.png")

But this does not work:

Quote:# initialize the cv2 QRCode detector
detector = cv2.QRCodeDetector() # whoops, doesn't work!

I get this in Idle:

Quote:>>> detector = cv2.QRCodeDetector()
Traceback (most recent call last):
File "<pyshell#20>", line 1, in <module>
detector = cv2.QRCodeDetector()
AttributeError: module 'cv2' has no attribute 'QRCodeDetector'

The webpage says it was updated September 2020.

I installed cv2 from Ubuntu: sudo apt-get install python3-opencv

How do I get the detector?
Reply
#2
If you do dir(cv2) in your REPL, do you get lots and lots of objects? Could you show some of the output?

If you don't, I suspect your cv2 module is being shadowed by some other file locally.

>>> len(dir(cv2))
1946
>>> dir(cv2)
['', 'ACCESS_FAST', 'ACCESS_MASK', 'ACCESS_READ', 'ACCESS_RW', 'ACCESS_WRITE', 'ADAPTIVE_THRESH_GAUSSIAN_C', 'ADAPTIVE_THRESH_MEAN_C', 'AGAST_FEATURE_DETECTOR_AGAST_5_8', 'AGAST_FEATURE_DETECTOR_AGAST_7_12D', 'AGAST_FEATURE_DETECTOR_AGAST_7_12S', 'AGAST_FEATURE_DETECTOR_NONMAX_SUPPRESSION', 'AGAST_FEATURE_DETECTOR_OAST_9_16', 'AGAST_FEATURE_DETECTOR_THRESHOLD', 'AKAZE', 'AKAZE_DESCRIPTOR_KAZE', 'AKAZE_DESCRIPTOR_KAZE_UPRIGHT', 'AKAZE_DESCRIPTOR_MLDB',
...
Reply
#3
EDIT: SOLVED: with advice from askubuntu, I downloaded

pedro@pedro-512ssd:~$ pip3 install opencv-contrib-python

Now the detector works!!

Thanks for the reply:

I got this info:

Quote:>>> cv2
<module 'cv2' from '/usr/lib/python3/dist-packages/cv2.cpython-36m-x86_64-linux-gnu.so'>
>>> len(dir(cv2))
1704
>>> dir(cv2) (gives "squeezed text" because the output is very long)

>>>

Looks like my cv2 is significantly shorter than your cv2 1704 to 1946!

Maybe that's why the module is missing!

How to change this? I have tried to install opencv- from pip3, but the install fails.

Quote:pedro@pedro-512ssd:~$ pip3 install opencv-python
Collecting opencv-python
Using cached https://files.pythonhosted.org/packages/....42.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-aop87qrl/opencv-python/setup.py", line 9, in <module>
import skbuild
ModuleNotFoundError: No module named 'skbuild'

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-aop87qrl/opencv-python/
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Prime number detector Mark17 5 736 Nov-27-2023, 12:53 PM
Last Post: deanhystad
  problem in using pyqrcode module to create QRcode akbarza 9 1,799 Aug-23-2023, 04:17 PM
Last Post: snippsat
  Face detector project? korenron 2 2,075 Mar-24-2021, 03:43 PM
Last Post: korenron
  can't read QRcode in large file simoneek 0 1,476 Sep-16-2020, 08:52 AM
Last Post: simoneek
  Smoke detector + send email Brandon99 4 3,912 Sep-12-2018, 11:18 PM
Last Post: Brandon99
  Vowels and Consonants detector OmarSinno 5 9,710 Sep-21-2017, 02:27 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020