BaselineData BHFitsImageSet::loadData(const ImageSetIndex &index) { const BHFitsImageSetIndex &fitsIndex = static_cast<const BHFitsImageSetIndex&>(index); TimeFrequencyMetaDataPtr metaData(new TimeFrequencyMetaData()); TimeFrequencyData data; loadImageData(data, metaData, fitsIndex); return BaselineData(data, metaData, index); }
//////////////////////////////////////////////////////////////////////////////// //! Run a simple benchmark test for CUDA //////////////////////////////////////////////////////////////////////////////// void runBenchmark( int argc, char **argv ) { int devID = 0; shrLog("[runBenchmark]: [%s]\n", sSDKsample); devID = cutilChooseCudaDevice(argc, argv); loadImageData(argc, argv); initCuda(); g_CheckRender = new CheckBackBuffer(width, height, 4, false); g_CheckRender->setExecPath(argv[0]); unsigned int *d_result; cutilSafeCall( cudaMalloc( (void **)&d_result, width*height*sizeof(unsigned int)) ); // warm-up boxFilterRGBA(d_img, d_temp, d_temp, width, height, filter_radius, iterations, nthreads); cutilSafeCall( cutilDeviceSynchronize() ); // Start round-trip timer and process iCycles loops on the GPU iterations = 1; // standard 1-pass filtering const int iCycles = 150; double dProcessingTime = 0.0; shrLog("\nRunning BoxFilterGPU for %d cycles...\n\n", iCycles); shrDeltaT(2); for (int i = 0; i < iCycles; i++) { dProcessingTime += boxFilterRGBA(d_img, d_temp, d_img, width, height, filter_radius, iterations, nthreads); } // check if kernel execution generated an error and sync host cutilCheckMsg("Error: boxFilterRGBA Kernel execution FAILED"); cutilSafeCall(cutilDeviceSynchronize()); // Get average computation time dProcessingTime /= (double)iCycles; // log testname, throughput, timing and config info to sample and master logs shrLogEx(LOGBOTH | MASTER, 0, "boxFilter-texture, Throughput = %.4f M RGBA Pixels/s, Time = %.5f s, Size = %u RGBA Pixels, NumDevsUsed = %u, Workgroup = %u\n", (1.0e-6 * width * height)/dProcessingTime, dProcessingTime, (width * height), 1, nthreads); shrLog("\n"); }
//////////////////////////////////////////////////////////////////////////////// //! Run a simple benchmark test for CUDA //////////////////////////////////////////////////////////////////////////////// int runBenchmark(int argc, char **argv) { printf("[runBenchmark]: [%s]\n", sSDKsample); loadImageData(argc, argv); initCuda(); unsigned int *dResult; size_t pitch; checkCudaErrors(cudaMallocPitch((void **)&dResult, &pitch, width*sizeof(unsigned int), height)); sdkStartTimer(&kernel_timer); // warm-up bilateralFilterRGBA(dResult, width, height, euclidean_delta, filter_radius, iterations, kernel_timer); checkCudaErrors(cudaDeviceSynchronize()); // Start round-trip timer and process iCycles loops on the GPU iterations = 1; // standard 1-pass filtering const int iCycles = 150; double dProcessingTime = 0.0; printf("\nRunning BilateralFilterGPU for %d cycles...\n\n", iCycles); for (int i = 0; i < iCycles; i++) { dProcessingTime += bilateralFilterRGBA(dResult, width, height, euclidean_delta, filter_radius, iterations, kernel_timer); } // check if kernel execution generated an error and sync host getLastCudaError("Error: bilateralFilterRGBA Kernel execution FAILED"); checkCudaErrors(cudaDeviceSynchronize()); sdkStopTimer(&kernel_timer); // Get average computation time dProcessingTime /= (double)iCycles; // log testname, throughput, timing and config info to sample and master logs printf("bilateralFilter-texture, Throughput = %.4f M RGBA Pixels/s, Time = %.5f s, Size = %u RGBA Pixels, NumDevsUsed = %u\n", (1.0e-6 * width * height)/dProcessingTime, dProcessingTime, (width * height), 1); printf("\n"); return 0; }
void runAutoTest(int argc, char **argv, const char *dump_filename, eFilterMode filter_mode) { cudaDeviceProp deviceProps; int devID = findCudaDevice(argc, (const char **)argv); checkCudaErrors(cudaGetDeviceProperties(&deviceProps, devID)); printf("[%s] (automated testing w/ readback)\n", sSDKsample); printf("CUDA device [%s] has %d Multi-Processors\n", deviceProps.name, deviceProps.multiProcessorCount); loadImageData(argc, argv); uchar4 *d_output; checkCudaErrors(cudaMalloc((void **)&d_output, imageWidth*imageHeight*4)); unsigned int *h_result = (unsigned int *)malloc(width * height * sizeof(unsigned int)); printf("AutoTest: %s Filter Mode: <%s>\n", sSDKsample, sFilterMode[g_FilterMode]); render(imageWidth, imageHeight, tx, ty, scale, cx, cy, blockSize, gridSize, filter_mode, d_output); // check if kernel execution generated an error getLastCudaError("Error: render (bicubicTexture) Kernel execution FAILED"); checkCudaErrors(cudaDeviceSynchronize()); cudaMemcpy(h_result, d_output, imageWidth*imageHeight*4, cudaMemcpyDeviceToHost); sdkSavePPM4ub(dump_filename, (unsigned char *)h_result, imageWidth, imageHeight); checkCudaErrors(cudaFree(d_output)); free(h_result); // cudaDeviceReset causes the driver to clean up all state. While // not mandatory in normal operation, it is good practice. It is also // needed to ensure correct operation when the application is being // profiled. Calling cudaDeviceReset causes all profile data to be // flushed before the application exits cudaDeviceReset(); }
void runAutoTest(int argc, char **argv) { int devID = 0; shrLog("[runAutoTest]: [%s] (automated testing w/ readback)\n", sSDKsample); devID = cutilChooseCudaDevice(argc, argv); loadImageData(argc, argv); initCuda(); g_CheckRender = new CheckBackBuffer(width, height, 4, false); g_CheckRender->setExecPath(argv[0]); unsigned int *d_result; cutilSafeCall( cudaMalloc( (void **)&d_result, width*height*sizeof(unsigned int)) ); for(int i = 0; i < 4; i++) { shrLog("[AutoTest]: %s (radius=%d)", sSDKsample, filter_radius ); bilateralFilterRGBA(d_result, width, height, euclidean_delta, filter_radius, iterations, nthreads); // check if kernel execution generated an error cutilCheckMsg("Error: bilateralFilterRGBA Kernel execution FAILED"); cutilSafeCall( cutilDeviceSynchronize() ); cudaMemcpy(g_CheckRender->imageData(), d_result, width*height*sizeof(unsigned int), cudaMemcpyDeviceToHost); g_CheckRender->savePPM(sOriginal[i], false, NULL); if (!g_CheckRender->PPMvsPPM(sOriginal[i], sReference[i], MAX_EPSILON_ERROR, 0.15f)) { g_TotalErrors++; } gaussian_delta += 1.0f; euclidean_delta *= 1.25f; updateGaussian(gaussian_delta, filter_radius); } cutilSafeCall( cudaFree( d_result ) ); delete g_CheckRender; }
void ProcessImage::insertNewData(int index, QList<struct DetectorData> detectedData){ showCase->setDone( index ); if (detectedData.size() == 0){ detectedFaces->noFace(); } else { QList<struct FaceData> facedata; struct FaceData f; for (int i = 0; i < detectedData.size(); i++ ){ f.rect = detectedData.at(i).rect; f.image = detectedData.at(i).image; f.personId = -1; f.eigen_ratio = 0; f.fisher_ratio = 0; f.lbph_ratio = 0; f.voted = false; facedata << f; } showCase->addCoordinates( index, facedata ); } // RECOGNIZE THE FACES // recognizer = new Recognizer(); for (int i = 0; i < detectedData.size(); i++ ){ qDebug() << "send image " << i << " to recognition"; Socket::sock().recognize( detectedData.at(i).mat.clone(), index, i ); // int personId = recognizer->recognize( detectedData.at(i) ); // showCase->setPersonId(index, i, personId); // image index, face index, person id } /* show if current */ if (index == _currentImage){ loadImageData( index ); } }
void initialize(int argc, char **argv) { printf("[%s] (OpenGL Mode)\n", sSDKsample); // First initialize OpenGL context, so we can properly set the GL for CUDA. // This is necessary in order to achieve optimal performance with OpenGL/CUDA interop. initGL(&argc, argv); int devID; cudaDeviceProp deviceProps; if (checkCmdLineFlag(argc, (const char **)argv, "device")) { devID = gpuGLDeviceInit(argc, (const char **)argv); if (devID < 0) { printf("exiting...\n"); exit(EXIT_SUCCESS); } } else { devID = gpuGetMaxGflopsDeviceId(); cudaGLSetGLDevice(devID); } // get number of SMs on this GPU checkCudaErrors(cudaGetDeviceProperties(&deviceProps, devID)); printf("CUDA device [%s] has %d Multi-Processors\n", deviceProps.name, deviceProps.multiProcessorCount); // Create the timer (for fps measurement) sdkCreateTimer(&timer); // load image from disk loadImageData(argc, argv); printf("\n" "\tControls\n" "\t=/- : Zoom in/out\n" "\tb : Run Benchmark g_FilterMode\n" "\tc : Draw Bicubic Spline Curve\n" "\t[esc] - Quit\n\n" "\tPress number keys to change filtering g_FilterMode:\n\n" "\t1 : nearest filtering\n" "\t2 : bilinear filtering\n" "\t3 : bicubic filtering\n" "\t4 : fast bicubic filtering\n" "\t5 : Catmull-Rom filtering\n\n" ); initGLBuffers(); #if USE_BUFFER_TEX fprog = compileASMShader(GL_FRAGMENT_PROGRAM_ARB, shaderCode); if (!fprog) { exit(EXIT_SUCCESS); } #endif }
//////////////////////////////////////////////////////////////////////////////// // Program main //////////////////////////////////////////////////////////////////////////////// int main(int argc, char **argv) { // start logs int devID; char *ref_file = NULL; printf("%s Starting...\n\n", argv[0]); #if defined(__linux__) setenv ("DISPLAY", ":0", 0); #endif // use command-line specified CUDA device, otherwise use device with highest Gflops/s if (argc > 1) { if (checkCmdLineFlag(argc, (const char **)argv, "radius")) { filter_radius = getCmdLineArgumentInt(argc, (const char **) argv, "radius"); } if (checkCmdLineFlag(argc, (const char **)argv, "passes")) { iterations = getCmdLineArgumentInt(argc, (const char **)argv, "passes"); } if (checkCmdLineFlag(argc, (const char **)argv, "file")) { getCmdLineArgumentString(argc, (const char **)argv, "file", (char **)&ref_file); } } // load image to process loadImageData(argc, argv); if (checkCmdLineFlag(argc, (const char **)argv, "benchmark")) { // This is a separate mode of the sample, where we are benchmark the kernels for performance devID = findCudaDevice(argc, (const char **)argv); // Running CUDA kernels (bilateralfilter) in Benchmarking mode g_TotalErrors += runBenchmark(argc, argv); // cudaDeviceReset causes the driver to clean up all state. While // not mandatory in normal operation, it is good practice. It is also // needed to ensure correct operation when the application is being // profiled. Calling cudaDeviceReset causes all profile data to be // flushed before the application exits cudaDeviceReset(); exit(g_TotalErrors == 0 ? EXIT_SUCCESS : EXIT_FAILURE); } else if (checkCmdLineFlag(argc, (const char **)argv, "radius") || checkCmdLineFlag(argc, (const char **)argv, "passes")) { // This overrides the default mode. Users can specify the radius used by the filter kernel devID = findCudaDevice(argc, (const char **)argv); g_TotalErrors += runSingleTest(ref_file, argv[0]); // cudaDeviceReset causes the driver to clean up all state. While // not mandatory in normal operation, it is good practice. It is also // needed to ensure correct operation when the application is being // profiled. Calling cudaDeviceReset causes all profile data to be // flushed before the application exits cudaDeviceReset(); exit(g_TotalErrors == 0 ? EXIT_SUCCESS : EXIT_FAILURE); } else { // Default mode running with OpenGL visualization and in automatic mode // the output automatically changes animation printf("\n"); // First initialize OpenGL context, so we can properly set the GL for CUDA. // This is necessary in order to achieve optimal performance with OpenGL/CUDA interop. initGL(argc, (char **)argv); int dev = findCapableDevice(argc, argv); if (dev != -1) { dev = gpuGLDeviceInit(argc, (const char **)argv); if (dev == -1) { exit(EXIT_FAILURE); } } else { // cudaDeviceReset causes the driver to clean up all state. While // not mandatory in normal operation, it is good practice. It is also // needed to ensure correct operation when the application is being // profiled. Calling cudaDeviceReset causes all profile data to be // flushed before the application exits cudaDeviceReset(); exit(EXIT_SUCCESS); } // Now we can create a CUDA context and bind it to the OpenGL context initCuda(); initGLResources(); // sets the callback function so it will call cleanup upon exit #if defined (__APPLE__) || defined(MACOSX) atexit(cleanup); #else glutCloseFunc(cleanup); #endif printf("Running Standard Demonstration with GLUT loop...\n\n"); printf("Press '+' and '-' to change filter width\n" "Press ']' and '[' to change number of iterations\n" "Press 'e' and 'E' to change Euclidean delta\n" "Press 'g' and 'G' to changle Gaussian delta\n" "Press 'a' or 'A' to change Animation mode ON/OFF\n\n"); // Main OpenGL loop that will run visualization for every vsync glutMainLoop(); } }
//////////////////////////////////////////////////////////////////////////////// // Program main //////////////////////////////////////////////////////////////////////////////// int main( int argc, char** argv) { pArgc = &argc; pArgv = argv; shrQAStart(argc, argv); // start logs shrSetLogFileName ("boxFilter.txt"); shrLog("%s Starting...\n\n", argv[0]); // use command-line specified CUDA device, otherwise use device with highest Gflops/s if (argc > 1) { cutGetCmdLineArgumenti( argc, (const char**) argv, "threads", &nthreads ); cutGetCmdLineArgumenti( argc, (const char**) argv, "radius", &filter_radius); if (cutCheckCmdLineFlag(argc, (const char **)argv, "glverify")) { g_bOpenGLQA = true; fpsLimit = frameCheckNumber; } if (cutCheckCmdLineFlag(argc, (const char **)argv, "fbo")) { g_bFBODisplay = true; } } // load image to process loadImageData(argc, argv); if (cutCheckCmdLineFlag(argc, (const char **)argv, "qatest") || cutCheckCmdLineFlag(argc, (const char **)argv, "noprompt")) { // Running CUDA kernel (boxFilter) without visualization (QA Testing/Verification) runAutoTest(argc, argv); shrQAFinishExit(argc, (const char **)argv, (g_TotalErrors == 0 ? QA_PASSED : QA_FAILED)); } else if (cutCheckCmdLineFlag(argc, (const char **)argv, "benchmark")) { // Running CUDA kernels (boxfilter) in Benchmarking mode runBenchmark(argc, argv); shrQAFinishExit(argc, (const char **)argv, (g_TotalErrors == 0 ? QA_PASSED : QA_FAILED)); } else { // Running CUDA kernels (boxFilter) with OpenGL visualization if (g_bFBODisplay) shrLog("[FBO Display] "); if (g_bOpenGLQA) shrLog("[OpenGL Readback Comparisons] "); shrLog("\n"); if ( cutCheckCmdLineFlag(argc, (const char **)argv, "device")) { printf(" This SDK does not explicitly support -device=n when running with OpenGL.\n"); printf(" When specifying -device=n (n=0,1,2,....) the sample must not use OpenGL.\n"); printf(" See details below to run without OpenGL:\n\n"); printf(" > %s -device=n -qatest\n\n", argv[0]); printf("exiting...\n"); shrQAFinishExit(argc, (const char **)argv, QA_WAIVED); } // First initialize OpenGL context, so we can properly set the GL for CUDA. // This is necessary in order to achieve optimal performance with OpenGL/CUDA interop. initGL( &argc, argv ); int dev = findCapableDevice(argc, argv); if( dev != -1 ) { cudaGLSetGLDevice( dev ); } else { cutilDeviceReset(); shrQAFinishExit(argc, (const char **)argv, QA_WAIVED); } // Now we can create a CUDA context and bind it to the OpenGL context initCuda(); initGLResources(); if (g_bOpenGLQA) { if (g_bFBODisplay) { g_CheckRender = new CheckFBO(width, height, 4, g_FrameBufferObject); } else { g_CheckRender = new CheckBackBuffer(width, height, 4); } g_CheckRender->setPixelFormat(GL_RGBA); g_CheckRender->setExecPath(argv[0]); g_CheckRender->EnableQAReadback(true); } } // sets the callback function so it will call cleanup upon exit atexit(cleanup); shrLog("Running Standard Demonstration with GLUT loop...\n\n"); shrLog("Press '+' and '-' to change filter width\n" "Press ']' and '[' to change number of iterations\n\n"); // Main OpenGL loop that will run visualization for every vsync glutMainLoop(); cutilDeviceReset(); shrQAFinishExit(argc, (const char **)argv, (g_TotalErrors == 0 ? QA_PASSED : QA_FAILED)); }
//////////////////////////////////////////////////////////////////////////////// // Program main //////////////////////////////////////////////////////////////////////////////// int main( int argc, char** argv) { shrQAStart(argc, argv); // start logs shrSetLogFileName ("bilateralFilter.txt"); shrLog("%s Starting...\n\n", argv[0]); // use command-line specified CUDA device, otherwise use device with highest Gflops/s cutGetCmdLineArgumenti( argc, (const char**) argv, "threads", &nthreads ); cutGetCmdLineArgumenti( argc, (const char**) argv, "radius", &filter_radius); // load image to process loadImageData(argc, argv); if (cutCheckCmdLineFlag(argc, (const char **)argv, "qatest") || cutCheckCmdLineFlag(argc, (const char **)argv, "noprompt")) { // Running CUDA kernel (bilateralFilter) without visualization (QA Testing/Verification) runAutoTest(argc, argv); shrQAFinishExit(argc, (const char **)argv, (g_TotalErrors == 0 ? QA_PASSED : QA_FAILED)); } else if (cutCheckCmdLineFlag(argc, (const char **)argv, "benchmark")) { // Running CUDA kernel (bilateralFilter) in Benchmarking Mode runBenchmark(argc, argv); shrQAFinishExit(argc, (const char **)argv, (g_TotalErrors == 0 ? QA_PASSED : QA_FAILED)); } else { // Running CUDA kernel (bilateralFilter) in CUDA + OpenGL Visualization Mode if ( cutCheckCmdLineFlag(argc, (const char **)argv, "device")) { printf("[%s]\n", argv[0]); printf(" Does not explicitly support -device=n in OpenGL mode\n"); printf(" To use -device=n, the sample must be running w/o OpenGL\n\n"); printf(" > %s -device=n -qatest\n", argv[0]); printf("exiting...\n"); exit(0); } // First initialize OpenGL context, so we can properly set the GL for CUDA. // This is necessary in order to achieve optimal performance with OpenGL/CUDA interop. initGL( argc, argv ); if ( cutCheckCmdLineFlag(argc, (const char **)argv, "device")) { cutilGLDeviceInit(argc, argv); } else { cudaGLSetGLDevice (cutGetMaxGflopsDeviceId() ); } initCuda(); initOpenGL(); } atexit(cleanup); printf("Running Standard Demonstration with GLUT loop...\n\n"); printf("Press '+' and '-' to change number of iterations\n" "Press LEFT and RIGHT change euclidean delta\n" "Press UP and DOWN to change gaussian delta\n" "Press '1' to show original image\n" "Press '2' to show result\n\n"); glutMainLoop(); cutilDeviceReset(); shrQAFinishExit(argc, (const char **)argv, (g_TotalErrors == 0 ? QA_PASSED : QA_FAILED)); }
ImageView::ImageView(QWidget * parent) : QGraphicsView(parent) { loadImageData(ImageView::sample1src); }
/** * Reloads original image */ void ImageView::reloadImageData() { loadImageData(imageSource); }
//////////////////////////////////////////////////////////////////////////////// // Program main //////////////////////////////////////////////////////////////////////////////// int main(int argc, char **argv) { int devID = 0; char *ref_file = NULL; pArgc = &argc; pArgv = argv; // start logs printf("%s Starting...\n\n", argv[0]); if (checkCmdLineFlag(argc, (const char **)argv, "help")) { printHelp(); exit(EXIT_SUCCESS); } // use command-line specified CUDA device, otherwise use device with highest Gflops/s if (argc > 1) { if (checkCmdLineFlag(argc, (const char **)argv, "threads")) { nthreads = getCmdLineArgumentInt(argc, (const char **) argv, "threads"); } if (checkCmdLineFlag(argc, (const char **)argv, "radius")) { filter_radius = getCmdLineArgumentInt(argc, (const char **) argv, "radius"); } if (checkCmdLineFlag(argc, (const char **)argv, "passes")) { iterations = getCmdLineArgumentInt(argc, (const char **) argv, "passes"); } if (checkCmdLineFlag(argc, (const char **)argv, "file")) { getCmdLineArgumentString(argc, (const char **)argv, "file", (char **)&ref_file); } } // load image to process loadImageData(argc, argv); if (checkCmdLineFlag(argc, (const char **)argv, "benchmark")) { // This is a separate mode of the sample, where we are benchmark the kernels for performance devID = findCudaDevice(argc, (const char **)argv); // Running CUDA kernels (boxfilter) in Benchmarking mode g_TotalErrors += runBenchmark(); exit(g_TotalErrors == 0 ? EXIT_SUCCESS : EXIT_FAILURE); } else if (checkCmdLineFlag(argc, (const char **)argv, "radius") || checkCmdLineFlag(argc, (const char **)argv, "passes")) { // This overrides the default mode. Users can specify the radius used by the filter kernel devID = findCudaDevice(argc, (const char **)argv); g_TotalErrors += runSingleTest(ref_file, argv[0]); exit(g_TotalErrors == 0 ? EXIT_SUCCESS : EXIT_FAILURE); } else { // Default mode running with OpenGL visualization and in automatic mode // the output automatically changes animation printf("\n"); // First initialize OpenGL context, so we can properly set the GL for CUDA. // This is necessary in order to achieve optimal performance with OpenGL/CUDA interop. initGL(&argc, argv); int dev = findCapableDevice(argc, argv); if (dev != -1) { cudaGLSetGLDevice(dev); } else { cudaDeviceReset(); exit(EXIT_SUCCESS); } // Now we can create a CUDA context and bind it to the OpenGL context initCuda(); initGLResources(); // sets the callback function so it will call cleanup upon exit atexit(cleanup); printf("Running Standard Demonstration with GLUT loop...\n\n"); printf("Press '+' and '-' to change filter width\n" "Press ']' and '[' to change number of iterations\n" "Press 'a' or 'A' to change animation ON/OFF\n\n"); // Main OpenGL loop that will run visualization for every vsync glutMainLoop(); cudaDeviceReset(); exit(g_TotalErrors == 0 ? EXIT_SUCCESS : EXIT_FAILURE); } }