Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Sorting objects on a tranportation belt with object recognition

2 views
Skip to first unread message

peter veres

unread,
Sep 2, 2010, 3:49:19 PM9/2/10
to
Hello to eveybody.
I have an interesting project to do at my University.
A transportation belt with a web camera up from it. The task is to recognize the comming object: round, square or other.
An IR barrier detects the overcomming object, the microcontroller stops the belt and sends a stop caracter to the PC (USB to serial adapter).
After the recognition, Matlab sends a single caracter over the serial port to a microcontroler (L -for left, R for right, N for neutral). The final step is a sliding door what suppose to made the selection: right for round, left for square, neutral for the unrecognized shape.
My problems started when I try to read a caracter coming from the serial port . After many hours of reading and listening webinars at Mathworks, I don't know how to make this. I tryed some examples but no results.
The second problem is to recognise the shape and made the difference. I also tryed the "blister pack" demo from here, but a lot of error ocured. I use R2007b.
Writing to serial port is OK, but it takes 2 seconds to execute a simple "R" sending to port... My computer runs winXP, 2G of RAM at a speed of 1600.
It's too long time, no?
So, any help is welcomed, even if a small part of this because now I am stuck...
Thank you for everyone.

ImageAnalyst

unread,
Sep 2, 2010, 4:03:22 PM9/2/10
to
Shouldn't be too difficult, as long as your objects don't overlap. In
fact if they are all the same size, you could just check the area of
the objects and might not need anything else. For example if all your
round objects are about 10 cm^2 and all your square objects are about
40 cm^2, just check the area of each blob to find out if it's closer
to the round object's area or the square object's area, then that will
tell you what kind of object it is.
Try my image segmentation demo:
http://www.mathworks.com/matlabcentral/fileexchange/25157
You can adapt it to measure shape by looking at the (perimeter^2/area)
ratio if you really need to.

Walter Roberson

unread,
Sep 2, 2010, 4:09:54 PM9/2/10
to

Using a USB to serial adapter is _part_ of the problem but not all of it.

The stop character that the micro-controller sends to the PC: is it a single
character (or string of known length), or is it that followed by a line
terminator? If it is _not_ followed by the same line terminator as you have
configured the serial object to expect, then when you go to read the
character, the read will have to wait until it times out; if there is no
terminator, you should explicitly configure the serial port not to use a
terminator, and you should in that case probably use fread() to read the
character.

Likewise, if the microcontroller is expecting a terminator but you are not
sending one, the microcontroller level would either wait for-ever or would
time out. If the serial object is set up to expect a terminator and you are
not sending one, then the serial data might not be sent until the serial
object times-out the send.

USB to serial adapters compound the problem because they make it impossible to
send data asynchronously at the defined speed: the USB drivers will not
transmit to the adapter until there is a 40 ms pause in activity or until you
instruct the drivers to "push" the data out. (They are designed this way
because USB is designed for efficiency with larger blocks of data, not for
real-time work.)


I do not have any hints about the shape recognition; I would advise, though,
that it would be easier for us if you were to make available some sample
images and to describe the recognition problems you are seeing.

peter veres

unread,
Sep 4, 2010, 3:34:03 AM9/4/10
to
My configuration doesn't send and receives terminator, simple it sends to PC a # caracter... I send to microcontroller a simple R or L caracter to move the sorting mechanism.
How can I make manual snapsot when the # comes?
Thank you for your aswer

Walter Roberson <robe...@hushmail.com> wrote in message <i5p0db$r8b$1...@canopus.cc.umanitoba.ca>...

ImageAnalyst

unread,
Sep 4, 2010, 9:05:35 AM9/4/10
to
I just bought the Image Acquisition Toolbox and within one hour I was
up and running, taking snapshots, so I'm sure you could be too. This
is the basic process:

1. Install the operating system drivers for the camera. Check with
Device Manager (if in Windows) to verify that Windows can see your
camera
2. Run the software that came with your camera to verify operation of
your camera. If all this works, you're ready to try it with MATLAB.
3. Get the Image Acquisition Toolbox and install it.
4. Install any special MATLAB software provided by your camera
manufacturer (if any is required, might not be).
5. Run imaqtool
6. Click Preview and start playing around with the camera settings
(exposure, etc.).
7. Copy the code in the imaqtool command window to your code.
8. Roll out your code to the plant.
9. Start sorting objects on your transportation belt.
10. Earn big bucks and retire to Hawaii.

peter veres

unread,
Oct 12, 2010, 11:37:03 AM10/12/10
to
Hello
There was very interesting and humorous answer.....
So, in the mean time I solved many problems with my sistem, it's working fine but still have a little problem with it.
Using regionprops to extract area and perimeter from a binary image I get the same value for perimeter: 1116 for any kind of object I use.
O course it's only one object, filtering small objects and using binary image.
The formula for calculating shapes is:
s=regionprops(L,'perimeter','area');
a=s.Perimeter^2/s.Area;
with selecting:
((a>17) && (a<20)) for square
((a>13) && (a<17)) for circle
Is something wrong with using regionprops? I saw that others used this function in shape recognition too....
Some ideas please?
Thank you very much
Peter


ImageAnalyst <imagea...@mailinator.com> wrote in message <95716929-b2b0-4493...@e14g2000yqe.googlegroups.com>...


> I just bought the Image Acquisition Toolbox and within one hour I was

> up and running, taking snapshots, so I'm sure you coulbe too. This

0 new messages