loading
 
outputting blob information
Greg Locke from New Zealand  [3 posts]
14 year
Hi, I am using roborealm to detect certain colored items in a frame (at 15fps from a camera), feed the corrdinates of those items to an external program which then controls some other hardware accordingly in real time. Using sockets and COG I can send the coordinates of a single item, but to handle multiple items I am using the blob filter and creating a blob array. How can I get this array data out into the socket datastream? Is there another method of interfacing to roborealm to obtain this data that would be better? many thanks, Greg
Greg Locke from New Zealand  [3 posts] 14 year
Further to above I have extracted the blob data in the 4 byte format in the blob array using the socket module. Is there an easy piece of C code for converting these 4 bytes to the real value?

Is it possible the Blob location data in the blob array is in a format other than straight integer as it almost seems the last byte is actually fractions of an integer.

Many thanks, Greg
Greg Locke from New Zealand  [3 posts] 14 year
OK.. some more progress... it seems the four bytes for the blob array COG locations output to the socket module are in float format, not integer. Can anyone confirm this as all the documentation states it as being integer? But I have loaded the 4 char bytes into a float structure (was a bit tricky) and it does indeed finally give the correct numbers.

To give information as fractions of a pixel seems a bit strange. I am using RoboRealm version 2.11.7.

Does anyone have more information on this, and maybe have some nice code for extracting the groups of 4 bytes and converting to individual float values, or maybe changing it so the information is sent as four byte integers instead of floats?

Many thanks, Greg
Anonymous 14 year
Hi Greg,

You are correct in that the format is floating point based. It used to be integer but folks wanted sub pixel accuracy which was why it was switched. With COG information you can get sub pixel as the center of gravity is based on the summation of the position of all pixels which when calculated will become decimal based.

I'm not sure which interface you are using (API, Plugins, etc) but an easy way to convert from an int to a float representation when it is in a floating point format is

int test;

float val = *((float *)&test);

i.e. you cast the address of the integer into a float and then dereference that address like a float. Note that this assumes test is in fact a 4 byte floating point representation on an intel machine. If you just want to cast an int into a float that is much easier but does not apply in your situation.

STeven.



Greg from New Zealand  [2 posts] 14 year
Thanks Steven.. I only just saw your reply, I must have been away when it came through. Thankyou for the explanation, it is indeed working good now.. though I have some new some speed questions which you will see me in my next post :)

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index