Raspberry Pi 4 Object Detection - A Camera Question

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