static gboolean process (GeglOperation *operation, GeglBuffer *out_buf, const GeglRectangle *roi, gint level) { GeglBufferIterator *iter; const Babl *out_format = gegl_operation_get_format (operation, "output"); if (gegl_operation_use_opencl (operation)) { GeglBufferClIterator *cl_iter; gboolean err; GEGL_NOTE (GEGL_DEBUG_OPENCL, "GEGL_OPERATION_POINT_RENDER: %s", GEGL_OPERATION_GET_CLASS (operation)->name); cl_iter = gegl_buffer_cl_iterator_new (out_buf, roi, out_format, GEGL_CL_BUFFER_WRITE); while (gegl_buffer_cl_iterator_next (cl_iter, &err) && !err) { err = cl_process (operation, cl_iter->tex[0], cl_iter->roi); if (err) { gegl_buffer_cl_iterator_stop (cl_iter); break; } } if (err) GEGL_NOTE (GEGL_DEBUG_OPENCL, "Error: %s", GEGL_OPERATION_GET_CLASS (operation)->name); else return TRUE; } iter = gegl_buffer_iterator_new (out_buf, roi, level, out_format, GEGL_ACCESS_WRITE, GEGL_ABYSS_NONE); while (gegl_buffer_iterator_next (iter)) c_process (operation, iter->data[0], &iter->roi[0]); return TRUE; }
/* Iterates through the classification directory, passing each image to the * c_process() function which performs the actual classification */ void NumberClassifier::classify(void) { int n = c_numbers; if (n < 0) { std::cerr << "Error opening directory" << std::endl; } while (n--) { std::string img_name = std::string(c_list[n]->d_name); int img_num = img_name.at(0) - 0x30; cv::Mat img = cv::imread(c_dir + img_name, CV_LOAD_IMAGE_COLOR); if (img.empty()) std::cerr << "Image not loaded" << std::endl; else { pre_process(img); int guess = c_process(img); if (img_num == guess) correct.at(img_num)++; guesses.at(img_num)++; } delete c_list[n]; } delete c_list; }