- status = cudaMemcpy2D(out.data(), out.stride(), d_out, out_pitch, bpp * width, height, cudaMemcpyDeviceToHost);
- if (status != cudaSuccess) {
- goto on_error_proc;
- }
-
- // free device memories
- cudaFree(d_out);
- cudaFree(d_in);
-
- return;
-
- // error handling
-on_error_proc:
- cudaFree(d_out);
-on_error_out:
- cudaFree(d_in);
-on_error_in:
- throw std::runtime_error(cudaGetErrorString(status));
-}
-
-__global__
-void
-FM7b5::binarize(uint8_t* out, const size_t out_pitch, const uint8_t* in, const size_t in_pitch, const size_t width, const size_t height, const uint8_t thres)
-{
- const size_t w(blockDim.x * blockIdx.x + threadIdx.x);
- const size_t h(blockDim.y * blockIdx.y + threadIdx.y);
-
- if (w >= width || h >= height) {
- return;
- }
-
- out[out_pitch * h + w] = (in[in_pitch * h + w] < thres) ? 0 : 255;
+ d_out.copy_to(out.data(), bpp * width, height, out.stride());