/*Returns same pixel values for red, green & blue channels if a single channel information is demanded. * Thus same computational methods (atleast for Avg, L1 & L1Sqrt Norms)can be used for the computation of features*/ void ProcessImage::Process(Image &image, vector<REAL>&r, vector<REAL>& g, vector<REAL>& b) { switch (channel) { case WandellOCS: case SandeOCS: ProcessOCS(image, r, g, b); break; case HSL: ProcessHSL(image, r, g, b); break; case RGB: ProcessRGB(image, r, g, b); break; case Gray: ProcessGray(image, r); copy(r.begin(), r.end(), g.begin()); copy(r.begin(), r.end(), b.begin()); break; case Red: case Green: case Blue: case ABSGradientMag: Process(image, r); copy(r.begin(), r.end(), g.begin()); copy(r.begin(), r.end(), b.begin()); break; } }
/* return malloced data which is the etc compressed texture of the source */ void CompressDataETC(const unsigned char *data, int dim, int size, unsigned char *tex_data, volatile bool &b_abort) { wxASSERT(dim*dim == 2*size || (dim < 4 && size==8)); // must be 4bpp uint64_t *tex_data64 = (uint64_t*)tex_data; int mbrow = wxMin(4, dim), mbcol = wxMin(4, dim); uint8_t block[48] = {}; for(int row=0; row<dim; row+=4) { for(int col=0; col<dim; col+=4) { for(int brow=0; brow<mbrow; brow++) for(int bcol=0; bcol<mbcol; bcol++) memcpy(block + (bcol*4+brow)*3, data + ((row+brow)*dim + col+bcol)*3, 3); extern uint64_t ProcessRGB( const uint8_t* src ); *tex_data64++ = ProcessRGB( block ); } if(b_abort) break; } }
void KinectSensorV1::Update() { if (NULL == m_pNuiSensor) { return; } if (WAIT_OBJECT_0 == WaitForSingleObject(m_hNextDepthFrameEvent, 0)) { ProcessDepth(); } if (WAIT_OBJECT_0 == WaitForSingleObject(m_hNextColorFrameEvent, 0)) { ProcessColor(); } if (cRevieveRGB && WAIT_OBJECT_0 == WaitForSingleObject(m_hNextRGBFrameEvent, 0)) { ProcessRGB(); } }
void RT_RayTracer::renderFrameETC() { uint32_t* fb1 = (uint32_t*)frameBuffer->getFrameBuffer(); uint32_t* fb2 = (uint32_t*)blockFB->getFrameBuffer(); const int widthFB1 = frameBuffer->getSizeX(); // width of full frame buffer, e.g. 1280 for 1280x720 int widthFB2 = widthFB1; if (Engine::rectMode) { widthFB2 = Engine::rectSizeX; // width of rect, e.g. 640 if only one half of the full frame buffer should be rendered } look(); taskManager.deleteAllTasks(); createRenderingTasks(); if (Engine::server) { auto etc1_fun = [&] (size_t i) { // render the tile to get RGBA data into the framebuffer taskManager.tasks[i]->run(); auto src = fb1 + widthFB1 * Engine::RENDERLINE_SIZE * i; if (Engine::rectMode) { src += Engine::rectBottom * widthFB1 + Engine::rectLeft; // offset the RGBA access until the bottom (lower part) of the rect starts and on the left side } auto dst = fb2 + widthFB2 * Engine::RENDERLINE_SIZE * i; // copy RGBA data from fb1 into the blockwise-oriented fb2 for (int blockY = 0; blockY < Engine::RENDERLINE_SIZE/4; blockY++) { // if RENDERLINE_SIZE=4 then this loop will only be executed once for (int blockX = 0; blockX < widthFB2 / 4; blockX++) { for (int x = 0; x < 4; x++) { for (int y = 0; y < 4; y++) { *dst++ = *src; src += widthFB1; } src -= widthFB1 * 4 - 1; } } src += widthFB1 * 3; // if RENDERLINE_SIZE=4 then this is irrelevant as src will not be used later } auto etc = ((uint64_t*)etcdata) + i * widthFB2 / 4; auto etcsrc = ((uint8_t*)fb2) + widthFB2 * Engine::RENDERLINE_SIZE * i * 4; // loop through the blockwise-oriented fb2 and compress RGBA into ETC1 and store this in etc/etcdata. for (size_t i = 0; i < widthFB2*Engine::RENDERLINE_SIZE / 16; ++i) { #if 0 Dither( etcsrc ); #endif *etc++ = ProcessRGB( etcsrc ); etcsrc += 4*4*4; } }; auto ompf_dispatch = [&] () { size_t e = taskManager.tasks.size(); #pragma omp parallel for for (size_t i = 0; i < e; ++i) { etc1_fun(i); } }; auto ompt_dispatch = [&] () { #pragma omp parallel #pragma omp single for (size_t i = 0, e = taskManager.tasks.size(); i < e; ++i) { #pragma omp task etc1_fun(i); } }; auto cilk_dispatch = [&] () { for (size_t i = 0, e = taskManager.tasks.size(); i < e; ++i) { #ifdef __cilk cilk_spawn(etc1_fun(i)); #else etc1_fun(i); #endif } #ifdef __cilk cilk_sync; #endif }; auto task_dispatch = [&] () { for (size_t i = 0, e = taskManager.tasks.size(); i < e; ++i) { TaskDispatch::Queue([&etc1_fun, i] { etc1_fun(i); }); } TaskDispatch::Sync(); }; switch (Engine::methodToMultiThread) { case MultiThreadMethods::TASKDISPATCH: task_dispatch(); break; case MultiThreadMethods::OPENMP: ompf_dispatch(); break; case MultiThreadMethods::OPENMPT: ompt_dispatch(); break; case MultiThreadMethods::CILK: cilk_dispatch(); break; } } else { renderScene(); } }