Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00036
00037
00038 #include "p_driver.h"
00039 using namespace Stg;
00040
00041 InterfaceBlobfinder::InterfaceBlobfinder( player_devaddr_t addr,
00042 StgDriver* driver,
00043 ConfigFile* cf,
00044 int section )
00045 : InterfaceModel( addr, driver, cf, section, "blobfinder" )
00046 {
00047
00048 }
00049
00050
00051 void InterfaceBlobfinder::Publish( void )
00052 {
00053 player_blobfinder_data_t bfd;
00054 bzero( &bfd, sizeof(bfd) );
00055
00056 ModelBlobfinder* blobmod = (ModelBlobfinder*)this->mod;
00057
00058 uint32_t bcount = 0;
00059 const ModelBlobfinder::Blob* blobs = blobmod->GetBlobs( &bcount );
00060
00061 if ( bcount > 0 )
00062 {
00063
00064 bfd.width = blobmod->scan_width;
00065 bfd.height = blobmod->scan_height;
00066 bfd.blobs_count = bcount;
00067
00068 bfd.blobs = new player_blobfinder_blob_t[ bcount ];
00069
00070
00071
00072
00073 unsigned int b;
00074 for( b=0; b<bcount; b++ )
00075 {
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087 int dx = blobs[b].right - blobs[b].left;
00088 int dy = blobs[b].top - blobs[b].bottom;
00089
00090 bfd.blobs[b].x = blobs[b].left + dx/2;
00091 bfd.blobs[b].y = blobs[b].bottom + dy/2;
00092
00093 bfd.blobs[b].left = blobs[b].left;
00094 bfd.blobs[b].right = blobs[b].right;
00095 bfd.blobs[b].top = blobs[b].top;
00096 bfd.blobs[b].bottom = blobs[b].bottom;
00097
00098 bfd.blobs[b].color =
00099 ((uint8_t)(blobs[b].color.r*255.0) << 16) +
00100 ((uint8_t)(blobs[b].color.g*255.0) << 8) +
00101 ((uint8_t)(blobs[b].color.b*255.0));
00102
00103 bfd.blobs[b].area = dx * dy;
00104
00105 bfd.blobs[b].range = blobs[b].range;
00106 }
00107 }
00108
00109
00110
00111
00112 this->driver->Publish( this->addr,
00113 PLAYER_MSGTYPE_DATA,
00114 PLAYER_BLOBFINDER_DATA_BLOBS,
00115 &bfd, sizeof(bfd), NULL);
00116 if ( bfd.blobs )
00117 delete [] bfd.blobs;
00118 }
00119
00120 int InterfaceBlobfinder::ProcessMessage( QueuePointer& resp_queue,
00121 player_msghdr_t* hdr,
00122 void* data )
00123 {
00124
00125
00126
00127 {
00128
00129 PRINT_WARN2( "blobfinder doesn't support msg with type/subtype %d/%d",
00130 hdr->type, hdr->subtype);
00131 return(-1);
00132 }
00133 }
00134