Raspberry Pi 4 Object Detection - A Camera Question

Hello @TechDevTom,

Just to make sure, which python version are you using?

Regards,

Louis

Yeah @TechDevTom could you output the values of:

$ python3 --version
$ pip3 --version
1 Like

Hey @louis @janjongboom, I’m using Python version 3.7.3 and pip version 18.1

Are there specific versions that I should be using? Do I need to place the python code in a specific location for it to work, or can it be placed anywhere on the SD card that I’m using?

Thanks for the assist so far!

@TechDevTom,

Could you provide the full output of the commands mentioned by Jan?
If you have multiple Python3 versions installed, pip3 may be pointing out to another version than 3.7.3.

Thanks,
Aurelien

@aurel @janjongboom Here you go, and, interestingly enough, on the pip3 command it mentions python 3.7, rather than python 3.7.3 at the end of it. Could this be an issue, or is just not printing out the full version?

Sorry to pester @janjongboom/@louis, do you have any more input on the above issue please?

Hey @TechDevTom,

Do you also have python 2 installed on your RPi? Can you make sure you run your python code using python 3. Otherwise, I am kind of running out of suggestion :confused:

Maybe try removing python & pip and do a clean install again to see if that fixes it.

Let us know of it goes.

Louis

Hi @TechDevTom you can try:

python3 -m pip install  edge_impulse_linux

To make sure it’s the matching Python version (for some f*n reason I have 8 different Pythons on my work laptop all with their own list of packages, so I feel your pain).

@louis @janjongboom Apparently I DID have Python 2 installed on my RPi! Annoying! I followed the advice on this link by Seamus and the code runs now: https://raspberrypi.stackexchange.com/questions/118760/uninstall-python2-in-raspberry-pi

Should I be feeding arguments into the command when I run it?

Never mind, got it, working nicely I think, thanks guys! Now to run some images through it and get it into the weatherproof case :smiley:

Will keep you informed of my progress if you want!

3 Likes

Hey all, just wanted to say that I’ve had good success over the last two days of running my model! I’ve gathered more data for making the model a bit more accurate (plant pots are not animals) and have been training the model as I go along.

I’ve hit a snag though, so will post a new topic up for that so others can find it easily if they run into a similar issue.

3 Likes

@janjongboom @aurel Hey guys, quick question, I notice that the image is cropped using the “runner.get_features_from_image(img)” call. Is there any way to process the entire image?

I’ve got code running to draw bounding boxes around birds that are detected by motion using cv2, but sometimes the bird is on the edge of the screen, and as I’m drawing bounding boxes around the “processed” image, the bird is no longer in screen!

Any help would be appreciated! I’m getting some really good shots with the camera btw, see attached :smiley: The Blackbird shot didn’t actually come through as a “something”, it came through as a nothing. I must need more bird close ups haha!

The two Bullfinches were a surprise, as I had one in earlier in the year but didn’t know I had a pair in. This is a good example of how the cropping effects the overall box drawn image though. It’s cutting out the Bullfinch on the left :open_mouth:

The pigeon shot is a good demo of the box drawing I have going on though!

image_07-07-2021_19:09:47_BoundingBoxes


image_08-07-2021_17:08:52_BoundingBoxes

The issue is that the model is trained on square images (and we don’t support non-square for now). One way around this would be to slice the image from webcam into two images and classify them both to not miss anything.

Here’s an example: https://github.com/edgeimpulse/linux-sdk-python/blob/master/examples/image/classify-full-frame.py

(You’ll need to upgrade to 1.0.4 of the Python package)

Ah I see, darn! I’ll give that split image thing a go, quite handy. I might need to analyse full images at some point in the future in one shot though, are there any plans to develop this ability @janjongboom?

I’m using the Object Detection code I’ve written to crop images down for the Image Classification section of the app, very handy :smiley:

@TechDevTom For normal image classification you can already do it, but we only have square object detection models available for now - most research is also going into square images, so I wouldn’t expect this to change very soon (cc @dansitu)

@janjongboom Interesting! I haven’t come across many squares resolution cameras before, I wonder why then people are using square images? Intriguing. Thanks for the heads up, I’ll build that knowledge into the work that I do :+1:

Great to see your model working! One thing you could try if you need the full camera frame is to reduce the size so it fits into the square box, and then pad the extra space with black pixels.

Warmly,
Dan

@janjongboom I tried the Left/Right image code, but I’m getting an error when fitting it into my own code: “TypeError: get_features_from_image() takes 2 positional arguments but 3 were given”. I copied what was in your example into my own code: “features_l, cropped_l = runner.get_features_from_image(img, ‘left’)”

Any ideas what I might be doing wrong?

@dansitu Yeah, it’s working really well, thanks for creating such an efficient platform :smiley: I see what you’re saying, I might give that a try at some point.

@TechDevTom Sorry missed your reply here! What’s the exact code that you pass in? Literally just

features_l, cropped_l = runner.get_features_from_image(img, ‘left’)

?

Are you on the latest Python package (1.0.4)?

Hey @janjongboom, no worries, I’m guessing you have lots to reply to!

Since the great catastrophe (me messing up my SD card with crontab/having to reinstall everything) I’m not actually having trouble with my code any more, it seems to work fine. Less work for you :smiley:

1 Like