Object and Animal Recognition With Raspberry Pi and OpenCV

Hi, James!

Thank you for your reply! I am using raspberry pi 3 model B for my project.

-Kyung

3 Likes

Thank you Tim! I think we can make communication via Youtube comments! I can also contact with James on this webpage :slight_smile: Thank you so much for helping me out, Tim!

-Kyung

3 Likes

im having same problem as russell174548 with the import cv2

2 Likes

I’ve updated this article (all Open-CV articles in fact) and gone through the Terminal Command process with Object and Animal Recognition. I have it working here and the most important take-away is to do this process using the previous Raspberry Pi ‘Buster’ OS release.

Newwer with timestamp

Until there is correct compatibility of OPEN-CV with the new Raspberry Pi ‘Bullseye’ OS I highly recommend at this stage flashing and using the previous Raspberry Pi ‘Buster’ OS onto your Micro-SD for use with any Open-CV guide. Updates are coming out fast and all the teething issues from this new OS will be ironed out soon.

So I’ve created this guide How to Flash the Old ‘Buster’ Raspberry Pi OS to a Micro-SD so everyone can know exactly how to go about doing this. Official ‘Buster’ Image Download Link is found here

4 Likes

Hi Tim, I was from the YouTube comment and I’m trying to use a Text To Speech software to say out loud the name of any object the code is able to detect. I’m having some trouble on a few things. How would I make it so that the if the same object stays on the screen for a while, to stop saying it’s name out loud, and only resume when a NEW object has been spotted? Thanks for the help.

5 Likes

Also one more thing, I’m pretty sure this code looks by each frame and determines if the object is in the database. But is it possible to have the code check every ‘x’ frames? Thanks.

4 Likes

Hi Niseem,

That’ll be super easy! In the Python code in the guide, the getObjects function spits out two things, an image, and a list of all the objects it found in an image, each one a smaller list of two elements, the object name, and the model’s confidence that it got it right.

Let me know if this needs more sense added to it!
-James

4 Likes

tried installing old buster os as you showed and actually got more errors

4 Likes

Hi JT,

What error messages were you getting now? It might be a simple fix like a missing dependency.

4 Likes

Send through the errors and we will get you back on track and have it working as it should :slight_smile:

4 Likes

Hi, I was able to have the code read and identify objects using all of the code that you have in the documentation the first time I ran the code. Recently when I tried to re-run the code but I am presented with these errors about the RuntimeModule, ImportError, and import cv2 error. lease let me how I can fix this issue. Thank you __________________________________________________________________________________Machine info-
NumPy 1.16.2
OpenCV 4.4.0
Raspberry (Buster OS 34)
Python 3.7.3

ERRORS RECEIVED-
File "/home/pi/.local/lib/python3.7/site-packages/cv2/__init__.py", line 9, in <module> from .cv2 import _registerMatType ImportError: numpy.core.multiarray failed to import "RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd Traceback (most recent call last): File "/home/pi/Desktop/Object_Detection_Files/object-ident-commented.py", line 2, in <module> import cv2"
Show less

3 Likes

What an interesting problem. Thanks for supplying all those details so elegantly I’m sure we can get you back to running the scripts like before.

Before I attempt to replicate your situation exactly over here the issue does appear to be some kind of compatibility issue with Numpy. So let’s try updating it using a couple of methods. Type and enter the below into the console.

pip3 install --upgrade numpy

If that doesn’t do the job try typing and entering the below. The first will provide all the numpy version details and the second is another method of updating numpy. Definitely provide those details back here if we have to troubleshoot further.

pip freeze | grep numpy
pip install -U numpy

3 Likes

Hi, I have a problem with the isntallation, it says there is no module named ‘cv2’ and I have no clue why. I took some pictures they might help.




2 Likes

Hey Vic,

Thanks kindly for the photos, they definitely speed up the troubleshooting process for me. Seeing that your background desktop image is that of ‘Bullseye’ OS that is the main culprit here. Bullseye OS is such a recent update to the Raspberry Pi Ecosystem that the team behind Open-CV hasn’t caught up and sorted full compatibility with it just yet. That is why you run into errors with | import cv2 |.

Whenever you use any of my Open-CV guides do so with the previous ‘Buster’ OS. Check out [this guide on how to flash your micro-SD card with it](https://core-electronics.com.au/tutorials/flash-buster-os-pi.html ]. Then you will need to go through the process of setting up Open-CV from the beginning.

Hope this helps, I’ll make sure you have it working and then you can send through photos of your system working :slight_smile:

4 Likes

Thank you and I will certainly do that!!

2 Likes

Hey Tim,

I flashed my micro-SD card, reinstalled everything but I still have the same problem. What is the next step to fixing this??

1 Like

Hi Vic,

Seems like something may have gone wrong during installation of OpenCV, I know this seems obvious, but have you followed the steps on installing OpenCV after flashing your OS again?

i.e. all these apt-gets etc?

-James

2 Likes

yep i did all of that

2 Likes

Hey Vic,

Sorry for not getting to you faster. Run the below line into your terminal. That should be the fix. If it does solve the problem I’ll be sure to update the actual guide and if you run into any other issues I’ll work through them with you.

sudo apt-get install python-opencv python3-opencv opencv-data

2 Likes

Hey,

I think we’re almost there, because it’s still not fully functioning


Uploading: 264294808_321688056482051_6466680178614099744_n.jpg…

3 Likes