Performance check ( opencv + tx1 camera )

I am trying usd opencv + tegra tx1 camera display ( 1080 60 fps )

cpu occupancy is high and delays occur…
i try image process… opencv + cuda
is there a better solution?

code

int
main(int argc, char **argv)
{
setenv (“DISPLAY”, “:0”, 0);

//char* gst = "nvcamerasrc ! video/x-raw(memory:NVMM), width=(int)1280, height=(int)720, format=(string)I420, framerate=(fraction)60/1 ! nvvidconv flip-method=2 ! videoconvert ! appsink";

// char* gst = “nvcamerasrc ! video/x-raw(memory:NVMM), width=(int)1280, height=(int)720,format=(string)I420, framerate=(fraction)60/1 ! nvvidconv flip-method=2 ! video/x-raw, format=(string)BGRx ! videoconvert ! ‘video/x-raw, format=(string)BGR’ ! appsink”;
char* gst = “nvcamerasrc ! video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, format=(string)I420, framerate=(fraction)60/1 ! nvvidconv flip-method=2 ! video/x-raw, format=(string)I420 ! videoconvert ! video/x-raw, format=(string)BGR ! appsink”;
if(camera.open(gst) ==false)
{
printf(“isOpened error \n”);
return 0;

}
camera.read(rawCamImage);


width = 1920;
height = 1080;


m_camBuffer = new unsigned char[width*height*3];
h_img = new unsigned char[width*height*3];
printf("Init VideoCapture \n");


int device;
struct cudaDeviceProp prop;
cudaGetDevice(&device);
cudaGetDeviceProperties(&prop, device);


initGL(&argc, argv);
//findCudaGLDevice(argc, (const char **)argv);

// initCudaBuffers();
initGLBuffers();
glutMainLoop();

exit(EXIT_SUCCESS);

}

void display()
{
camera.read(rawCamImage);

glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB,pbo);
glBufferData(GL_PIXEL_UNPACK_BUFFER_ARB , width*height*3 , 0 , GL_STREAM_DRAW_ARB );

GLubyte* ptr = (GLubyte*)glMapBuffer(GL_PIXEL_UNPACK_BUFFER_ARB , GL_WRITE_ONLY_ARB);
if( ptr )
{
    memcpy(ptr , rawCamImage.data ,width*height*3 );
    glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER_ARB);
}

// load texture from pbo
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, pbo);
glBindTexture(GL_TEXTURE_2D, texid);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, 0);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0);

// display results
glClear(GL_COLOR_BUFFER_BIT);

glEnable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST);

glBegin(GL_QUADS);
glTexCoord2f(0, 1);
glVertex2f(0, 0);
glTexCoord2f(1, 1);
glVertex2f(1, 0);
glTexCoord2f(1, 0);
glVertex2f(1, 1);
glTexCoord2f(0, 0);
glVertex2f(0, 1);
glEnd();

glDisable(GL_TEXTURE_2D);
glutSwapBuffers();

}

Hi jin888547,

What is your purpose of using openCV? You can directly render the video from cameras by using gstreamer.

#30fps
gst-launch-1.0 nvcamerasrc fpsRange="30.0 30.0" ! 'video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, format=(string)I420, framerate=(fraction)30/1' ! nvtee ! nvvidconv flip-method=2 ! 'video/x-raw(memory:NVMM), format=(string)I420' ! nvoverlaysink -e

We intend to use various realtime image processing purposes.

Using opencv and cuda.( ex: Sharpness ,Blur etc… )

However, when tested, about 10 fps is display output… slow… this [ camera.read(rawCamImage); ] function…
Are there any examples that can control(Read and write images) 1080 60fps?

Hi jin888547,

We also provide multimedia_api that can do similar thing as your request.

If you want to use opencv, could you use imshow? It is a built-in funcion call that can render your frame to display.