Jetson TK1 OpenCV performance

Hello,

I was trying to use kinect and red object dection.

I was able to get kinect stream in opencv, and the red object code from http://opencv-srf.blogspot.com/2010/09/object-detection-using-color-seperation.html

Yet, when the frequency of the loop drastically went down with this 4 lines:

//morphological opening (remove small objects from the foreground)
erode(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(5, 5)) );
dilate( imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(5, 5)) );

//morphological closing (fill small holes in the foreground)
dilate( imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(5, 5)) );
erode(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(5, 5)) );

Interestingly, when I set max_cpu performance, the frequency drop is augmented a little bit. And GPU max performance didn’t change any.

I thought the opencv from jetpack uses GPU instead of CPU. Is there any other way I can boost up the frequency?

I’m not an expert, but I think you have to call the gpu functions or it will just use cpu.

eg. cv::gpu::dilate

Sadly cv::gpu::dilate or erode produces much worse performance compare to cv::dilate.

Hi el101001,

How you monitor the CPU and GPU freq?
By Tegrastats?

Could you share more information as reference?

Thanks

I just used

#include

to measure time elapse between the two points. For instance,

void function()

clock_t start = clock();

//codes to measure

double timeElapse = (double) (ends - start) / CLOCKS_PER_SEC;
double freq = 1/timeElapse;
std::cout << “Time elapsed: " << timeElapse <<” Frequency: " << freq << std::endl;

That’s the frequency of the specific codes in c++.

For CPU and GPU freq. (it is from http://elinux.org/Jetson/Performance)

#! /bin/sh
echo "CPU0 (kHz): "
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
echo "CPU1 (kHz): "
cat /sys/devices/system/cpu/cpu1/cpufreq/scaling_cur_freq
echo "CPU2 (kHz): "
cat /sys/devices/system/cpu/cpu2/cpufreq/scaling_cur_freq
echo "CPU3 (kHz): "
cat /sys/devices/system/cpu/cpu3/cpufreq/scaling_cur_freq

echo "GPU bus speed: "
cat /sys/kernel/debug/clock/gbus/rate
echo "GPU memory speed: "
cat /sys/kernel/debug/clock/emc/rate

So, based on these, I measured the time in c++ which was ~ 20 Hz with default cpu and gpu frequecy. And then, I increased CPU frequency (also from http://elinux.org/Jetson/Performance) and the measurement becomes 30Hz. But change in GPU frequency (either bus or memory) didn’t affect.

Hi el101001,

By experience on perf tests show the same discrepancy with the dilate function.
Please do the experiment with different sizes and CPU vs. GPU to find the optimal performance and quality trade off for your app.
It’s not exactly linear in the size of the dilate, so try smaller and larger sizes both to find the optimum performance point.
Hope this could help on your issue.

Thanks