Open Ariel-Rodriguez opened 5 years ago
Hey, thanks for sharing your experience. To save intermediate results, please look into "cvutil.h", there are helper functions to draw intermediate results. Such as "drawTriangleLineOnImg", "drawTriangle", and "drawVoronoi". They all return a cv::Mat type and you can then call "cv::imwrite" to save it as an image. For example:
cv::Mat triLine = drawTriangleLineOnImg(triangles, voronoi);
cv::imwrite("triangle_lines.png", triLine);
As for edge detection and selected points, I didn't write helper functions for them. You can refer to the following code. Here the "vertices" and "grad" are the just these two variables in LowPoly.cpp.
// write selected points to img
cv::Mat pts = cv::Mat(rows, cols, CV_32F, 0.0);
for (int i = 0; i < numVertices; i++)
{
int row = vertices[i].y;
int col = vertices[i].x;
pts.at<float>(row, col) = 255.0;
}
cv::imwrite("points.png", pts);
// write edge detection result to img
cv::Mat edges = grad * 255.0;
cv::imwrite("edges.png", edges);
@Ariel-Rodriguez Thanks a lot for sharing your experience!
As you see, this is actually a class project. We were working on a Linux machine in our lab that had CUDA and everything installed, and the README is basically a project report, so we did not mention how to compile and run it. It is actually strange to me that CUDA 9.0 and 10.0 do not work on it. I will check the CUDA version on our machine later on.
Besides, the reason that we linked opencv
rudely is that we could not install it on our lab machine without root privilege. So we had to copy the binaries to a specific folder and link to them.
Your comments will be extremely helpful for those who want to try it out!
Hey @DarkForte you welcome!
Thanks for thee feedback. There is no rush to check CUDA version. Just in case, if you are interested, here is the output when i use CUDA 10.1
/Developer/NVIDIA/CUDA-10.1/include/thrust/system/cuda/detail/cub/block/specializations/../../warp/specializations/warp_reduce_shfl.cuh(528): error: calling a __host__ function("std::__1::__clz") from a __device__ function("thrust::cuda_cub::cub::TilePrefixCallbackOp<int, ::thrust::plus<int> , ::thrust::cuda_cub::cub::ScanTileState<int, (bool)1> , (int)300> ::operator ()") is not allowed
/Developer/NVIDIA/CUDA-10.1/include/thrust/system/cuda/detail/cub/block/specializations/../../warp/specializations/warp_reduce_shfl.cuh(528): error: identifier "std::__1::__clz" is undefined in device code
/Developer/NVIDIA/CUDA-10.1/include/thrust/system/cuda/detail/cub/block/specializations/../../warp/specializations/warp_reduce_shfl.cuh(528): error: calling a __host__ function("std::__1::__clz") from a __device__ function("thrust::cuda_cub::cub::TilePrefixCallbackOp<int, ::thrust::plus<int> , ::thrust::cuda_cub::cub::ScanTileState<int, (bool)1> , (int)300> ::operator ()") is not allowed
/Developer/NVIDIA/CUDA-10.1/include/thrust/system/cuda/detail/cub/block/specializations/../../warp/specializations/warp_reduce_shfl.cuh(528): error: identifier "std::__1::__clz" is undefined in device code
4 errors detected in the compilation of "/var/folders/qt/_kpg344d58b6mzh8whj37hl40000gp/T//tmpxft_00007a40_00000000-6_delauneyGPU.cpp1.ii".
CMake Error at LowPoly_generated_delauneyGPU.cu.o.Debug.cmake:279 (message):
Error generating file
/Users/arielrodriguez/LowPoly/cmake-build-debug/src/CMakeFiles/LowPoly.dir//./LowPoly_generated_delauneyGPU.cu.o
nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Fri_Feb__8_19:08:19_PST_2019
Cuda compilation tools, release 10.1, V10.1.105
BTW: Do you have any other demo using GPU similar to this sample technique?https://www.learnopencv.com/non-photorealistic-rendering-using-opencv-python-c/
Note: I had to add this CMake option variable -DCUDA_CUDART_LIBRARY=/Developer/NVIDIA/CUDA-10.1/lib/libcudart.10.1.dylib
Hello! First of all thank you so much for sharing!
I'd like to share my experience about running this project in my Macbook OSX 10.14. As JS developer it was a nice challenge to compile and run :D so i am here to share my experience. So hope of utility for others
Cuda Toolkit 8.0 (even if you don't own NVIDIA in your system)
Add CUDA PATH to your .bashrc or .zshrc
Downgrade OSX Command Line Tools
Make sure you have xcode basics installed
Download CMT Mount DMG, Install the PKG
Get CMT from apple old archives: Download CLT for XCode 8.2 Dec 2016
Activate it (downgrade)
Install Opencv@3
Add paths to your bash profile
Configure opencv3:
Clone repository and edit CMakeLists.txt
I removed
-gencode arch=compute_61,code=sm_61
NVCC_FLAG and included opencv directoryEdit src/CMakeLists.txt
Find line with LINK_DIRECTORIES and change to follow
PATCH CUDA TOOLKIT LIBRARY
I had compilation errors at cuda library, you can fix and patch manually by your self: Edit as sudo following file
Change lines
return __all(cond);
intoreturn ::__all(cond);
return __any(cond);
intoreturn ::__any(cond);
Build with CLion
I found very useful IDE CLion for OSX, as JS dev it was easy to load CMakeLists.txt and rebuild.
Run
Questions:
@DarkForte @FredHuangBia can you give an example how to save Edge Detection and Selected vertices output as image?
Troubleshooting
This is how my env looks like