1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
#include "C_TSRClassify.h"
#include "Image/ByteImage.h"
#include "C_TSRReadout.h"
extern "C"
{
#include "classify.h"
#include "app.h"
}
void classify(int width, int height, int bpp, char* data)
{
// interpretation
//--------------------------
CByteImage::ImageType type;
if(bpp == 3)
{
type = CByteImage::eRGB24; // rgb
}
else if(bpp == 1)
{
type = CByteImage::eGrayScale;
}
CByteImage* pImg =
new CByteImage(width, height, type);
memcpy(pImg->pixels, data, width*height*bpp);
// processing
//-------------------------
// Classify module
C_TSRClassify* clasModule =
new C_TSRClassify();
clasModule->storeInputImage(pResImg);
// send results
//---------------------------------------
unsigned int unResAvail; // kein Zeiger....
unsigned char unSpeedValue;
unResAvail = clasModule->getAvailableResults();
clasModule->getResultClass(unspeedValue);
if(unResAvail > 0)
{
unsigned short tgt_addr = 0x101;
int width = unSpeedValue->width;
int height = unSpeedValue->height;
int bytesPerPixel = unSpeedValue->bytesPerPixel;
unsigned int length = width*height*bytesPerPixel;
unsigned char* data = (unsigned char* ) malloc(length + 4 + 4 + 4);
data[0] = (width >> 24) & 0xFF;
data[1] = (width >> 16) & 0xFF;
data[2] = (width >> 8) & 0xFF;
data[3] = (width ) & 0xFF;
data[4] = (height >> 24) & 0xFF;
data[5] = (height >> 16) & 0xFF;
data[6] = (height >> 8) & 0xFF;
data[7] = (height ) & 0xFF;
data[8] = (bpp >> 24) & 0xFF;
data[9] = (bpp >> 16) & 0xFF;
data[10] = (bpp >> 8) & 0xFF;
data[11] = (bpp ) & 0xFF;
for(int i = 0; i < length; i++)
{
data[i+12] = unSpeedValue->pixels[i];
}
int lengthRest = length + 12;
int x = 0;
while(lengthRest > 0) //length segment
{
lengthRest = lengthRest - 1024;
if(lengthRest > 0)
{
app_cmd_send_ams(tgt_addr, 0xAA, 0x00, 0xF00, 0xC, 1024, &data[x]);
x = 1024 + x;
}
else
{
int rest = lengthRest+1024;
app_cmd_send_ams(tgt_addr, 0xAA, 0x00, 0xF00, 0xC, 1024, &data[x]);
}
}
free(data);
clasModule->getResultClass(unSpeedValue);
}
// if
}
//classify
My whone program. was can i do ?
|