Ask Your Question

Durden's profile - activity

2020-04-19 18:45:50 -0500 received badge  Notable Question (source)
2018-10-03 08:13:50 -0500 received badge  Popular Question (source)
2017-10-27 07:41:05 -0500 asked a question Interactor in 3dViz

Interactor in 3dViz Hi, I am trying to implement a feature to select a set of points in a 3dViz window using the mouse.

2015-08-15 10:07:21 -0500 received badge  Enthusiast
2015-08-12 05:07:55 -0500 asked a question Performance GPU implementation on NVIDIA Jetson TK1


I recently have implemented a simple algorithm for GPU that works on the pixels of an image. It performs operations such as additions, subtractions, multiplications, divisions, max, split, merge etc. I am using NVIDIA Jetson TK1 for the experiments. I am comparing the performance of the same algorithm using GPU and CPU (of course I adapted the GPU code for CPU). The image is RGB of size 720x576.

I concluded that the algorithm on GPU is much much slower than that on CPU.

The majority of the time is used for the allocation of the memory. For example, this operation

cv::gpu::GpuMat img_gpu(host_img.size(), CV_8UC3);

takes on average 2 seconds. If I don't allocate the memory first and I do the upload, letting upload allocate the memory (I guess), i.e.

cv::gpu::GpuMat img_gpu;

it takes (roughly) the same time.

Also there are other operations that are faster on CPU, like split, converTo, Max. The code is pretty simple. It is just a bunch of operations, one after the other, done on the RGB channels independently.

My questions are. Am I doing something wrong? Am I missing something? Is the cache of the GPU too small to handle an image of 720x576?

Thanks in advance,


2015-08-12 03:18:05 -0500 received badge  Supporter (source)
2015-08-12 03:18:00 -0500 received badge  Scholar (source)
2015-08-11 06:00:31 -0500 asked a question atan on GPU


I am developing a function that does per-pixel operations on an image and there is a step where I have to compute the arctan (atan) for each pixel. I have not found any atan function for GPU that I can embed in my code. I pasted my code below.

Is there anyone that can help me with this problem? I would like to perform atan on GPU because I have other operations to do (e.g. pixels normalization etc.) afterwards.

Thank you in advace,


cv::Mat host_img = cv::imread("/home/ubuntu/myCodes/firstTest/img/frame.png");

// CPU declarations
cv::Mat b(host_img.size(), CV_8UC1);
cv::Mat g(host_img.size(), CV_8UC1);
cv::Mat r(host_img.size(), CV_8UC1);

cv::Mat b_norm(host_img.size(), CV_64FC1);
cv::Mat g_norm(host_img.size(), CV_64FC1);
cv::Mat r_norm(host_img.size(), CV_64FC1);

vector<cv::Mat> final_img;
cv::Mat out_img(host_img.size(), CV_8UC3);

// GPU declarations
cv::gpu::GpuMat img_gpu(host_img.size(), CV_8UC3);

cv::gpu::GpuMat b_gpu(host_img.size(), CV_8UC1);
cv::gpu::GpuMat g_gpu(host_img.size(), CV_8UC1);
cv::gpu::GpuMat r_gpu(host_img.size(), CV_8UC1);

vector<cv::gpu::GpuMat> chans_gpu(3);
chans_gpu[0].create(host_img.rows, host_img.cols, CV_8UC1);
chans_gpu[1].create(host_img.rows, host_img.cols, CV_8UC1);
chans_gpu[2].create(host_img.rows, host_img.cols, CV_8UC1);

cv::gpu::split(img_gpu, chans_gpu);

cv::gpu::max(chans_gpu[1], chans_gpu[2], b_gpu);
cv::gpu::max(chans_gpu[0], chans_gpu[2], g_gpu);
cv::gpu::max(chans_gpu[0], chans_gpu[1], r_gpu);

chans_gpu[0].convertTo(chans_gpu[0], CV_64FC1);
chans_gpu[1].convertTo(chans_gpu[1], CV_64FC1);
chans_gpu[2].convertTo(chans_gpu[2], CV_64FC1);

b_gpu.convertTo(b_gpu, CV_64FC1);
g_gpu.convertTo(g_gpu, CV_64FC1);
r_gpu.convertTo(r_gpu, CV_64FC1);

cv::gpu::divide(chans_gpu[0], b_gpu, b_gpu);
cv::gpu::divide(chans_gpu[1], g_gpu, g_gpu);
cv::gpu::divide(chans_gpu[2], r_gpu, r_gpu);;;;

for (int i=0 ; i<b.rows ; i++) {
    for (int j=0 ; j<b.cols ; j++) {<double>(i,j) = atan(<double>(i,j));<double>(i,j) = atan(<double>(i,j));<double>(i,j) = atan(<double>(i,j));
2015-08-10 08:20:58 -0500 asked a question Separate RGB channels in 3 Mat variables


I am try to separate the RGB values in 3 Mat variables in order to deal with them separately. I would like to use a simple code to understand the data structure of Mat for images.

The code I am trying is pasted below, but of course it does not work. Can anyone help me with this?

cv::Mat host_img = cv::imread("frame.png");
cv::Mat host_img_green(host_img.size(), CV_8UC1, cv::Scalar(0,0,0));
cv::Mat host_img_red(host_img.size(), CV_8UC1, cv::Scalar(0,0,0));
cv::Mat host_img_blue(host_img.size(), CV_8UC1, cv::Scalar(0,0,0));

for (int i=0 ; i<host_img.rows ; i++) {
    for (int j=0 ; j<host_img.cols ; j++) {<uchar>(i,j) =<cv::Vec3d>(i,j)[0];<uchar>(i,j) =<cv::Vec3d>(i,j)[1];<uchar>(i,j) =<cv::Vec3d>(i,j)[2];

cv::imshow("Result", host_img_green);

return 0;

Thanks in advance, Durden