-3

I have recently gained interest over this machine learning topic about image classification.
I am in no way a programmer, but I am a farmer who is very interested about it, and detecting the quality of fruits and vegetables is a very tedious and time consuming task, specially if you don't have the money to buy industrial machinery to perform this task at a small-medium scale.

I recently came across this tutorial (had to fix a lot of errors because it is really bad written, but it works):

https://imaginghub.com/projects/148-how-to-distinguish-apples-and-pears-with-raspberry-pi/documentation

Which basically is the building block of a future fruit/vegetable quality grader.

This conveyor belt is going to have an Arduino that will receive an output from the Python program, that output should activate servos to redirect each fruit/vegetable to its own basket.

Now I would like to know how can I get the label output from the net and transform it to a number for example:

apple = 1, orange = 2, cucumber = 3...

So whenever it's apple, Arduino receives a 1 that will light an LED (first this, then servo), same happens for orange and cucumber and so on.

Here are the 2 codes I believe have to do something with the box label output Deploy.py and yolo_net.py

Deploy.py is the one I run to get the live camera detector:

Deploy.ipynb

And this is yolo_net.py (if it helps somehow to answer my question):

yolo_net.py

Jeru Luke
  • 20,118
  • 13
  • 80
  • 87
  • 1
    This isn't directly programming related. Have you tried asking on https://arduino.stackexchange.com/ – user115014 Nov 17 '17 at 21:54
  • `if detected == "apple": serial.write(1)`? – gre_gor Nov 18 '17 at 01:20
  • I was reading both yolo_net.py and Deploy.py files and found the following: Line 40 of the file Deploy.py calls `frame = net.draw_detections(frame, boxes)` and **draw_detections** is found in yolo_net.py line 45, there you can see it returns **class_name**, that class name is what im interested in, it can be apple, pear, etc. Now, where should I add the line that is somehow like what @gre_gor suggested? is it in Deploy.py? or yolo_net.py? or where? something like: `if class_name = ''apple'': serial.write(1)`. I didnt post on arduino se because its more like a line on python, thank you! – DeibzCanneibz Nov 18 '17 at 22:58

1 Answers1

0

All you have to do is modify the yolo_net.py file and go under def draw_detections(self, image, boxes): over to line 63, it should say

cv2.putText  (image, class_name, (left, top - 12), 0, 1e-3 * h, self.colors[class_indx], thick//2)  

it is under that line that you should add what you want the arduino to perform.

mkrieger1
  • 19,194
  • 5
  • 54
  • 65