MCPcopy Create free account
hub / github.com/creatale/node-dv / thresholdRectToPixMicroBench

Function thresholdRectToPixMicroBench

deps/tesseract/opencl/openclwrapper.cpp:2345–2437  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2343}
2344
2345static double thresholdRectToPixMicroBench(GPUEnv *env, TessScoreEvaluationInputData input, ds_device_type type) {
2346 double time;
2347#if ON_WINDOWS
2348 LARGE_INTEGER freq, time_funct_start, time_funct_end;
2349 QueryPerformanceFrequency(&freq);
2350#elif ON_APPLE
2351 mach_timebase_info_data_t info = {0, 0};
2352 mach_timebase_info(&info);
2353 long long start, stop;
2354#else
2355 timespec time_funct_start, time_funct_end;
2356#endif
2357
2358 // input data
2359 unsigned char pixelHi = (unsigned char)255;
2360 int* thresholds = new int[4];
2361 thresholds[0] = pixelHi/2;
2362 thresholds[1] = pixelHi/2;
2363 thresholds[2] = pixelHi/2;
2364 thresholds[3] = pixelHi/2;
2365 int *hi_values = new int[4];
2366 thresholds[0] = pixelHi;
2367 thresholds[1] = pixelHi;
2368 thresholds[2] = pixelHi;
2369 thresholds[3] = pixelHi;
2370 //Pix* pix = pixCreate(width, height, 1);
2371 int top = 0;
2372 int left = 0;
2373 int bytes_per_line = input.width*input.numChannels;
2374
2375 // function call
2376 if (type == DS_DEVICE_OPENCL_DEVICE) {
2377#if ON_WINDOWS
2378 QueryPerformanceCounter(&time_funct_start);
2379#elif ON_APPLE
2380 start = mach_absolute_time();
2381#else
2382 clock_gettime( CLOCK_MONOTONIC, &time_funct_start );
2383#endif
2384
2385 OpenclDevice::gpuEnv = *env;
2386 int retVal = OpenclDevice::ThresholdRectToPixOCL(
2387 input.imageData, input.numChannels, bytes_per_line, thresholds,
2388 hi_values, &input.pix, input.height, input.width, top, left);
2389
2390#if ON_WINDOWS
2391 QueryPerformanceCounter(&time_funct_end);
2392 time = (time_funct_end.QuadPart-time_funct_start.QuadPart)/(double)(freq.QuadPart);
2393#elif ON_APPLE
2394 stop = mach_absolute_time();
2395 if (retVal == 0) {
2396 time = ((stop - start) * (double)info.numer / info.denom) / 1.0E9;
2397 ;
2398 } else {
2399 time = FLT_MAX;
2400 }
2401
2402#else

Callers 1

evaluateScoreForDeviceFunction · 0.85

Calls 2

SetImageMethod · 0.45

Tested by

no test coverage detected