You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

571 lines
23 KiB

5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
​
​
​
​
​
​
​
​
​
​
​
5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
​
​
​
​
5 years ago
5 years ago
​
​
​
​
​
​
​
5 years ago
​
​
​
​
​
​
​
​
​
​
​
5 years ago
​
​
​
5 years ago
​
5 years ago
​
5 years ago
5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
5 years ago
​
​
​
​
5 years ago
5 years ago
​
​
​
​
​
5 years ago
5 years ago
​
​
​
​
​
​
​
​
​
5 years ago
5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #include "rgooseNodeSensor.h"
  2. #include <opencv2/opencv.hpp>
  3. #define LOG( X ) m_pLog->Log( "NODSEN", this, X )
  4. #define LOG_ERROR( X ) m_pLog->Log( "NODSEN", this, _LOG_ERROR, X )
  5. argusNodeSensor::argusNodeSensor( uint32_t id ):argusNetNode( id ),m_oPosition(){
  6. m_pTargetFilter = NULL;
  7. m_pLog = basicLogCollection::getInstance();
  8. memset( &m_sLRF_DATA, 0, sizeof(DBC_LRF_DATA));
  9. if( m_pDBC ){
  10. DBC_LRF_DATA *tDATA = m_pDBC->getLRFData(m_sNodeData.aux_id);
  11. if( tDATA != NULL ) {
  12. memcpy( &m_sLRF_DATA, tDATA, sizeof(DBC_LRF_DATA));
  13. free( tDATA );
  14. };
  15. };
  16. };
  17. argusNodeSensor::argusNodeSensor( DBC_NODE_DATA *Data ):argusNetNode( Data ),m_oPosition(){
  18. m_pTargetFilter = NULL;
  19. m_pLog = basicLogCollection::getInstance();
  20. memset( &m_sLRF_DATA, 0, sizeof(DBC_LRF_DATA));
  21. if( m_pDBC ){
  22. DBC_LRF_DATA *tDATA = m_pDBC->getLRFData(m_sNodeData.aux_id);
  23. if( tDATA != NULL ) {
  24. memcpy( &m_sLRF_DATA, tDATA, sizeof(DBC_LRF_DATA));
  25. free( tDATA );
  26. };
  27. };
  28. };
  29. argusNodeSensor::~argusNodeSensor(){
  30. };
  31. #define SKIP_LINE_PIXELS 28
  32. #define HEIGHT 512
  33. #define WIDTH 1024
  34. // scale factor -> 4/9
  35. uint8_t *argusNodeSensor::create2dDraw( uint32_t *out_size, uint32_t *th_data, size_t th_size, uint16_t max_digital, int radial_shift, CSTR tpl, bool byMinimum ){
  36. uint8_t *RetVal = NULL;
  37. *out_size = 0;
  38. if( th_data != NULL && th_size != 0 ) {
  39. if ( fileExist( tpl ) ) {
  40. cv::Mat tImage = cv::imread( tpl, cv::IMREAD_UNCHANGED );
  41. int psize = th_size / ( sizeof( uint32_t ));
  42. float stp = 2.0f * ( M_PI / (float) psize );
  43. //float MR = m_sLRF_DATA.max_range;
  44. float S = ( M_PI / 3000.0f) * (float) radial_shift;
  45. int x0 = (tImage.cols >> 1);
  46. int y0 = (tImage.rows >> 1);
  47. float maxR = ((float) x0 ) * 0.98f;
  48. cv::Point pts[(psize << 1)];
  49. cv::Point ptt[(psize+2)];
  50. const cv::Point * ppt[1];
  51. int npp[1];
  52. const cv::Point * ppz[1];
  53. int npz[1];
  54. float rst;
  55. int rpt;
  56. uint16_t RANGE = 0;
  57. ptt[0].x = x0;
  58. ptt[0].y = y0;
  59. rst = maxR / ((float)(max_digital+1));
  60. rpt = 1;
  61. for( int i=0; i < psize; i++ ){
  62. if( byMinimum ) {
  63. RANGE = ( th_data[i] >> 16 ) & 0xFFFF;
  64. } else {
  65. RANGE = th_data[i] & 0xFFFF;
  66. };
  67. float ca = 0.0 - ( S + i * stp );
  68. if( RANGE > 0 ){
  69. pts[psize+i].x = x0 + maxR * cosf( ca );
  70. pts[psize+i].y = y0 + maxR * sinf( ca );
  71. if( RANGE > max_digital ){
  72. pts[i].x = pts[psize+i].x;
  73. pts[i].y = pts[psize+i].y;
  74. } else {
  75. float cr = (rst * RANGE);
  76. pts[i].x = x0 + cr * cosf( ca );
  77. pts[i].y = y0 + cr * sinf( ca );
  78. };
  79. } else {
  80. ptt[rpt].x = pts[psize+i].x = pts[i].x = x0 + maxR * cosf( ca );
  81. ptt[rpt].y = pts[psize+i].y = pts[i].y = y0 + maxR * sinf( ca );
  82. rpt++;
  83. };
  84. };
  85. ppt[0] = pts;
  86. npp[0] = ( psize<<1 );
  87. ppz[0] = ptt;
  88. npz[0] = ( rpt - 1);
  89. cv::Mat ttMOMO = cv::imread( tpl, cv::IMREAD_UNCHANGED );
  90. cv::fillPoly( ttMOMO, ppt, npp, 1, cv::Scalar( 0, 128, 255, 50 ), cv::LINE_8 );
  91. cv::fillPoly( ttMOMO, ppz, npz, 1, cv::Scalar( 0, 0, 0, 100 ), cv::LINE_8 );
  92. cv::addWeighted( tImage, 0.5, ttMOMO, 0.5, 0.0, tImage );
  93. ttMOMO.release();
  94. vector<int> compression_params;
  95. compression_params.push_back( cv::IMWRITE_PNG_COMPRESSION );
  96. compression_params.push_back(9);
  97. vector<uchar> buf;
  98. cv::imencode( ".png", tImage, buf, compression_params );
  99. tImage.release();
  100. *out_size = buf.size();
  101. RetVal = (uint8_t *) malloc( *out_size );
  102. if( RetVal ) {
  103. memcpy( RetVal, buf.data(), *out_size );
  104. } else *out_size =0;
  105. buf.clear();
  106. };
  107. };
  108. return RetVal;
  109. };
  110. bool argusNodeSensor::handleDeviceDraw( uint8_t kID, void *th_data, size_t th_size, bool byMinimum ){
  111. if( th_data == NULL ) return false;
  112. if( th_size == 0 ) return false;
  113. if( m_pDBC == NULL ) return false;
  114. m_pDBC->addDeviceDraw( getNodeID(), DRAW_MODE_RAW_DATA, kID, th_data, th_size );
  115. /*
  116. //Clear Old Draw
  117. CSTR old = m_pDBC->getLRFDraw( getNodeID() );
  118. if ( old ) {
  119. // delete old draw
  120. char filename[256];
  121. sprintf( filename, "data/device_draws/%s_100.png", old );
  122. if( fileExist( filename ) ){
  123. unlink( filename );
  124. };
  125. sprintf( filename, "data/device_draws/%s_50.png", old );
  126. if( fileExist( filename ) ){
  127. unlink( filename );
  128. };
  129. sprintf( filename, "data/device_draws/%s_25.png", old );
  130. if( fileExist( filename ) ){
  131. unlink( filename );
  132. };
  133. sprintf( filename, "data/device_draws/%s_12.png", old );
  134. if( fileExist( filename ) ){
  135. unlink( filename );
  136. };
  137. sprintf( filename, "data/device_draws/%s_map.png", old );
  138. if( fileExist( filename ) ){
  139. unlink( filename );
  140. };
  141. free( old );
  142. };
  143. */
  144. CSTR uid = getUniqID_MD5();
  145. if( uid == NULL ) return false;
  146. switch( getNodeType() ){
  147. case ARGUS_ALS_SENSOR:
  148. case ARGUS_LFS_SENSOR:
  149. case ARGUS_PLS_200_SENSOR:
  150. case ARGUS_PLS_360_SENSOR:
  151. case ARGUS_NET_PLS_200:{
  152. uint32_t tSize;
  153. uint8_t *tBuff = create2dDraw( &tSize, (uint32_t *) th_data, th_size, 1024, m_sLRF_DATA.base_shift, "data/assets/images/lfs_draw_empty_100.png" );
  154. if ( tBuff ) {
  155. m_pDBC->addDeviceDraw( getNodeID(), DRAW_MODE_2D_100, kID, tBuff, tSize );
  156. free( tBuff );
  157. };
  158. tBuff = create2dDraw( &tSize, (uint32_t *) th_data, th_size, 512, m_sLRF_DATA.base_shift, "data/assets/images/lfs_draw_empty_50.png" );
  159. if ( tBuff ) {
  160. m_pDBC->addDeviceDraw( getNodeID(), DRAW_MODE_2D_50, kID, tBuff, tSize );
  161. free( tBuff );
  162. };
  163. tBuff = create2dDraw( &tSize, (uint32_t *) th_data, th_size, 256, m_sLRF_DATA.base_shift, "data/assets/images/lfs_draw_empty_25.png" );
  164. if ( tBuff ) {
  165. m_pDBC->addDeviceDraw( getNodeID(), DRAW_MODE_2D_25, kID, tBuff, tSize );
  166. free( tBuff );
  167. };
  168. tBuff = create2dDraw( &tSize, (uint32_t *) th_data, th_size, 128, m_sLRF_DATA.base_shift, "data/assets/images/lfs_draw_empty_12.png" );
  169. if ( tBuff ) {
  170. m_pDBC->addDeviceDraw( getNodeID(), DRAW_MODE_2D_12, kID, tBuff, tSize );
  171. free( tBuff );
  172. };
  173. tBuff = create2dDraw( &tSize, (uint32_t *) th_data, th_size, 1024, m_sLRF_DATA.base_shift, "data/assets/images/2d_MAP.png" );
  174. if ( tBuff ) {
  175. m_pDBC->addDeviceDraw( getNodeID(), DRAW_MODE_MAP, kID, tBuff, tSize );
  176. free( tBuff );
  177. };
  178. break;
  179. };
  180. case ARGUS_3D_SENSOR:{
  181. char * emptyBG = "data/assets/images/empty_3d.png";
  182. thresholdNode * ptr = (thresholdNode *) th_data;
  183. if ( fileExist( emptyBG ) ) {
  184. cv::Mat tImage = cv::imread( emptyBG, cv::IMREAD_UNCHANGED );
  185. if( tImage.rows != 512 || tImage.cols != 1024 ){
  186. LOG_ERROR( "Background Image wrong size (should be 1024x512)!" );
  187. free( uid );
  188. return false;
  189. };
  190. uint8_t * tMemory = tImage.data;
  191. thresholdNode * cNode = NULL;
  192. uint8_t * cPixel = NULL;
  193. int pix = 0;
  194. int mem = 0;
  195. bool s_bit = false;
  196. bool no_data = false;
  197. float tVal;
  198. bool master = ( kID < 16 );
  199. for( int idx = 0; idx < ( TH_SIZE_NODES << 2 ); idx++ ) { // tik-tak
  200. if( ( idx % 4 ) == 0 ){
  201. mem++;
  202. if ( master ) {
  203. cNode = ptr + TH_SIZE_NODES - mem - 1;
  204. } else {
  205. cNode = ptr + mem - 1;
  206. };
  207. if( !s_bit ) s_bit = cNode->values.sbit;
  208. if( !no_data ) no_data = ( cNode->values.cnt == 0 );
  209. if( !s_bit && !no_data ){
  210. if( byMinimum ) {
  211. tVal = ((float)cNode->values.min) / 4096.f;
  212. } else {
  213. tVal = ((float)cNode->values.max) / 4096.f;
  214. };
  215. };
  216. };
  217. if( ( idx % 9 ) == 0 ){
  218. if( mem > ( SKIP_LINE_PIXELS * TH_LINE_NODES ) ) {
  219. cPixel = tMemory + (pix << 2);
  220. pix++;
  221. if( s_bit ) { // Set Red
  222. cPixel[0] = 0x00; cPixel[1] = 0x00; cPixel[2] = 0xff; cPixel[3] = 0xff;
  223. } else {
  224. if( no_data ) { // Set Blue
  225. cPixel[0] = 0xff; cPixel[1] = 0x00; cPixel[2] = 0x00; cPixel[3] = 0xff;
  226. } else {
  227. uint32_t tColor;
  228. tColor = interpolate( 0x000000ff, 0xffffffff, tVal );
  229. cPixel[0] = ( tColor >> 24 ) & 0xFF;
  230. cPixel[1] = ( tColor >> 16 ) & 0xFF;
  231. cPixel[2] = ( tColor >> 8 ) & 0xFF;
  232. cPixel[3] = tColor & 0xFF;
  233. };
  234. };
  235. s_bit = false;
  236. no_data = false;
  237. };
  238. };
  239. };
  240. char filename[256];
  241. sprintf( filename, "data/device_draws/%s_100.png", uid );
  242. //int RetVal = stbi_write_png( filename, 1024, 512, cSpace, tMemory, 1024 * cSpace );
  243. vector<int> compression_params;
  244. compression_params.push_back( cv::IMWRITE_PNG_COMPRESSION );
  245. compression_params.push_back(9);
  246. if(! cv::imwrite( filename, tImage, compression_params ) ){
  247. tImage.release();
  248. free( uid );
  249. return false;
  250. };
  251. tImage.release();
  252. #ifdef DEBUG_EXTRA
  253. LOG("Draw Saved!");
  254. #endif
  255. cv::Mat tMap( Q_SCAN_COUNT, TH_LINE_NODES, CV_8UC4 );
  256. #ifdef DEBUG_EXTRA
  257. LOG("Map Creating");
  258. #endif
  259. tMemory = tMap.data;
  260. for( int j = 0; j < Q_SCAN_COUNT; j++ ){
  261. for( int i = 0; i < TH_LINE_NODES; i++ ){
  262. //cNode = ptr+(j*i);
  263. //cNode = &ptr[ ( TH_LINE_NODES * j ) + i ];
  264. int ids = 0;
  265. int idd = 0;
  266. if ( master ) {
  267. //cNode = ptr+makeIds( i, j , true );
  268. //cPixel = tMemory+( cSpace * makeIds( i, j , false ));
  269. ids = makeIds( i, j , true );
  270. idd = 4 * makeIds( i, j , false );
  271. //cNode = ptr + ( i * j );
  272. //cPixel = tMemory + ( cSpace * i * j );
  273. } else {
  274. //cNode = ptr+makeIds( i, j , false );
  275. //cPixel = tMemory+( cSpace * makeIds( i, j , false ));
  276. ids = makeIds( i, j , false );
  277. idd = 4 * makeIds( i, j , false );
  278. };
  279. cNode = ptr + ids ;
  280. cPixel = tMemory + idd;
  281. if( 0 ) { // Monochrome
  282. #ifdef CHECK_SUN_BIT
  283. if( cNode->values.sbit ) {
  284. cPixel[0] = 0;
  285. } else {
  286. cPixel[0] = (uint8_t)((((float) cNode->values.min ) * 255.f ) / 4096.f );
  287. };
  288. #else
  289. cPixel[0] = (uint8_t)((((float) cNode->values.min ) * 255.f ) / 4096.f );
  290. #endif
  291. } else {
  292. #ifdef CHECK_SUN_BIT
  293. if( cNode->values.sbit ) {
  294. // Set Red
  295. cPixel[0] = 0x00;
  296. cPixel[1] = 0x00;
  297. cPixel[2] = 0xff;
  298. cPixel[3] = 0xff;
  299. } else {
  300. if( cNode->values.cnt == 0 ) {
  301. // Set Blue
  302. cPixel[0] = 0xff;
  303. cPixel[1] = 0x00;
  304. cPixel[2] = 0x00;
  305. cPixel[3] = 0xff;
  306. } else {
  307. uint32_t tColor;
  308. float tVal = ((float) cNode->values.min ) / 4096.f;
  309. tColor = interpolate( 0x000000ff, 0xffffffff, tVal );
  310. cPixel[0] = ( tColor >> 24 ) & 0xFF;
  311. cPixel[1] = ( tColor >> 16 ) & 0xFF;
  312. cPixel[2] = ( tColor >> 8 ) & 0xFF;
  313. cPixel[3] = tColor & 0xFF;
  314. };
  315. };
  316. #else
  317. if( cNode->values.cnt == 0 ) {
  318. // Set Blue
  319. cPixel[0] = 0xff;
  320. cPixel[1] = 0x00;
  321. cPixel[2] = 0x00;
  322. cPixel[3] = 0xff;
  323. } else {
  324. uint32_t tColor;
  325. float tVal = ((float) cNode->values.min ) / 4096.f;
  326. tColor = interpolate( 0x000000ff, 0xffffffff, tVal );
  327. cPixel[0] = ( tColor >> 24 ) & 0xFF;
  328. cPixel[1] = ( tColor >> 16 ) & 0xFF;
  329. cPixel[2] = ( tColor >> 8 ) & 0xFF;
  330. cPixel[3] = tColor & 0xFF;
  331. };
  332. #endif
  333. };
  334. };
  335. };
  336. sprintf( filename, "data/device_draws/%s_map.png", uid );
  337. LOG(filename);
  338. if(! cv::imwrite( filename, tMap, compression_params ) ){
  339. tMap.release();
  340. free( uid );
  341. return false;
  342. };
  343. tMap.release();
  344. m_pDBC->addLRFDraw( getNodeID(), TH_SIZE_NODES, uid, kID, 1, true );
  345. } else {
  346. LOG_ERROR( "Background Image is Not Found!" );
  347. free( uid );
  348. return false;
  349. };
  350. break;
  351. };
  352. };
  353. free( uid );
  354. return true;
  355. };
  356. /*
  357. #define STB_IMAGE_IMPLEMENTATION
  358. #include "../data/stbi/stb_image.h"
  359. #define STB_IMAGE_WRITE_IMPLEMENTATION
  360. #include "../data/stbi/stb_image_write.h"
  361. #undef STB_IMAGE_WRITE_IMPLEMENTATION
  362. #undef STB_IMAGE_IMPLEMENTATION
  363. bool argus3DLIDAR::saveTHPicture( thresholdNode *ptr, CSTR uid, bool master, bool byMinimum, bool monochrome ){
  364. uint8_t *tMemory = NULL;
  365. thresholdNode *cNode = NULL;
  366. uint8_t *cPixel = NULL;
  367. int cSpace;
  368. int x, y;
  369. tMemory = stbi_load( "data/assets/images/empty_3d.png", &x, &y, &cSpace, STBI_default );
  370. if( tMemory == NULL ){
  371. LOG_ERROR("Draw Memory Alloc Eror!");
  372. return false;
  373. };
  374. if( x != 1024 || y != 512 ){
  375. LOG("Wrong IMG Size!");
  376. free( tMemory );
  377. return NULL;
  378. };
  379. int pix = 0;
  380. int mem = 0;
  381. bool s_bit = false;
  382. bool no_data = false;
  383. float tVal;
  384. for ( int idx = 0; idx < ( TH_SIZE_NODES << 2 ); idx++ ) { // tik-tak
  385. if( ( idx % 4 ) == 0 ){
  386. mem++;
  387. if ( master ) {
  388. cNode = ptr + TH_SIZE_NODES - mem - 1;
  389. } else {
  390. cNode = ptr + mem - 1;
  391. };
  392. if( !s_bit ) s_bit = cNode->values.sbit;
  393. if( !no_data ) no_data = ( cNode->values.cnt == 0 );
  394. if( !s_bit && !no_data ){
  395. if( byMinimum ) {
  396. tVal = ((float)cNode->values.min) / 4096.f;
  397. } else {
  398. tVal = ((float)cNode->values.max) / 4096.f;
  399. };
  400. };
  401. };
  402. if( ( idx % 9 ) == 0 ){
  403. if( mem > ( SKIP_LINE_PIXELS * TH_LINE_NODES ) ) {
  404. cPixel = tMemory + (pix << 2);
  405. pix++;
  406. if( s_bit ) { // Set Red
  407. cPixel[0] = 0x00; cPixel[1] = 0xff; cPixel[2] = 0x00; cPixel[3] = 0xff;
  408. } else {
  409. if( no_data ) { // Set Blue
  410. cPixel[0] = 0x00; cPixel[1] = 0x00; cPixel[2] = 0xff; cPixel[3] = 0xff;
  411. } else {
  412. uint32_t tColor;
  413. tColor = interpolate( 0x000000ff, 0xffffffff, tVal );
  414. cPixel[0] = ( tColor >> 24 ) & 0xFF;
  415. cPixel[1] = ( tColor >> 16 ) & 0xFF;
  416. cPixel[2] = ( tColor >> 8 ) & 0xFF;
  417. cPixel[3] = tColor & 0xFF;
  418. };
  419. };
  420. s_bit = false;
  421. no_data = false;
  422. }
  423. };
  424. };
  425. char filename[256];
  426. sprintf( filename, "data/device_draws/%s_100.png", uid );
  427. int RetVal = stbi_write_png( filename, 1024, 512, cSpace, tMemory, 1024 * cSpace );
  428. free( tMemory );
  429. if( RetVal == 0 ) return false;
  430. if( monochrome ) {
  431. cSpace = 1;
  432. } else {
  433. cSpace = 4;
  434. };
  435. tMemory = (uint8_t *) malloc( TH_SIZE_NODES * cSpace );
  436. if( tMemory == NULL ){
  437. LOG_ERROR("Map Memory Alloc Eror!");
  438. return false;
  439. };
  440. for (int j = 0; j < Q_SCAN_COUNT; j++) {
  441. for ( int i = 0; i < TH_LINE_NODES; i++ ) {
  442. //cNode = ptr+(j*i);
  443. //cNode = &ptr[ ( TH_LINE_NODES * j ) + i ];
  444. int ids = 0;
  445. int idd = 0;
  446. if ( master ) {
  447. //cNode = ptr+makeIds( i, j , true );
  448. //cPixel = tMemory+( cSpace * makeIds( i, j , false ));
  449. ids = makeIds( i, j , true );
  450. idd = cSpace * makeIds( i, j , false );
  451. //cNode = ptr + ( i * j );
  452. //cPixel = tMemory + ( cSpace * i * j );
  453. } else {
  454. //cNode = ptr+makeIds( i, j , false );
  455. //cPixel = tMemory+( cSpace * makeIds( i, j , false ));
  456. ids = makeIds( i, j , false );
  457. idd = cSpace * makeIds( i, j , false );
  458. };
  459. cNode = ptr + ids ;
  460. cPixel = tMemory + idd;
  461. if( monochrome ) {
  462. #ifdef CHECK_SUN_BIT
  463. if( cNode->values.sbit ) {
  464. cPixel[0] = 0;
  465. } else {
  466. cPixel[0] = (uint8_t)((((float) cNode->values.min ) * 255.f ) / 4096.f );
  467. };
  468. #else
  469. cPixel[0] = (uint8_t)((((float) cNode->values.min ) * 255.f ) / 4096.f );
  470. #endif
  471. } else {
  472. #ifdef CHECK_SUN_BIT
  473. if( cNode->values.sbit ) {
  474. // Set Red
  475. cPixel[0] = 0x00;
  476. cPixel[1] = 0xff;
  477. cPixel[2] = 0x00;
  478. cPixel[3] = 0xff;
  479. } else {
  480. if( cNode->values.cnt == 0 ) {
  481. // Set Blue
  482. cPixel[0] = 0x00;
  483. cPixel[1] = 0x00;
  484. cPixel[2] = 0xff;
  485. cPixel[3] = 0xff;
  486. } else {
  487. uint32_t tColor;
  488. float tVal = ((float) cNode->values.min ) / 4096.f;
  489. tColor = interpolate( 0x000000ff, 0xffffffff, tVal );
  490. cPixel[0] = ( tColor >> 24 ) & 0xFF;
  491. cPixel[1] = ( tColor >> 16 ) & 0xFF;
  492. cPixel[2] = ( tColor >> 8 ) & 0xFF;
  493. cPixel[3] = tColor & 0xFF;
  494. };
  495. };
  496. #else
  497. if( cNode->values.cnt == 0 ) {
  498. // Set Blue
  499. cPixel[0] = 0x00;
  500. cPixel[1] = 0x00;
  501. cPixel[2] = 0xff;
  502. cPixel[3] = 0xff;
  503. } else {
  504. uint32_t tColor;
  505. float tVal = ((float) cNode->values.min ) / 4096.f;
  506. tColor = interpolate( 0x000000ff, 0xffffffff, tVal );
  507. cPixel[0] = ( tColor >> 24 ) & 0xFF;
  508. cPixel[1] = ( tColor >> 16 ) & 0xFF;
  509. cPixel[2] = ( tColor >> 8 ) & 0xFF;
  510. cPixel[3] = tColor & 0xFF;
  511. };
  512. #endif
  513. };
  514. };
  515. };
  516. sprintf( filename, "data/device_draws/%s_map.png", uid );
  517. RetVal = stbi_write_png( filename, TH_LINE_NODES, Q_SCAN_COUNT, cSpace, tMemory, TH_LINE_NODES * cSpace );
  518. free( tMemory );
  519. if( RetVal == 0 ) return false;
  520. return true;
  521. };
  522. */
  523. #undef LOG
  524. #undef LOG_ERROR