ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

error: variable cv::cuda::GpuMat has initializer but incomplete type

asked 2017-10-29 05:06:06 -0500

WLemkens gravatar image

updated 2017-11-04 12:15:54 -0500

I'm trying to use the CUDA implementation for OpenCV on the NVidia TX1.

Using cv::Mat, the minimal example below works, but with cv::cuda::GpuMat it returns errors when comiling:

#include "ros/ros.h"
#include <cv_bridge/cv_bridge.h>
#include <image_transport/image_transport.h>
#include <opencv2/imgproc/imgproc.hpp>

void imageCallback(const sensor_msgs::ImageConstPtr& original_image){
    cv_bridge::CvImagePtr cv_ptr;
    try     {       
        cv_ptr = cv_bridge::toCvCopy(original_image);   
    }   catch (cv_bridge::Exception& e)     {       
        ROS_ERROR("test::main.cpp::cv_bridge exception: %s", e.what());
        return;     
    }   
    cv::cuda::GpuMat yuvImage = cv_ptr->image;
    cv::cuda::GpuMat rgbImage;
}

int main(int argc, char **argv){
    ros::init(argc, argv, "test");
    ros::NodeHandle n;
    ros::Subscriber image_sub = n.subscribe("/camera/image_raw", 1, imageCallback);
    ros::spin();
}

The errors I get with catkin buildare:

/home/wim/catkin-ws/src/test/src/test.cpp: In function ‘void imageCallback(const ImageConstPtr&)’:
/home/wim/catkin-ws/src/test/src/test.cpp:19:34: error: variable ‘cv::cuda::GpuMat yuvImage’ has initializer but incomplete type
  cv::cuda::GpuMat yuvImage(tmpMat);
                                  ^
/home/wim/catkin-ws/src/test/src/test:20:19: error: aggregate ‘cv::cuda::GpuMat rgbImage’ has incomplete type and cannot be defined
  cv::cuda::GpuMat rgbImage;

What am I doing wrong? The OpenCV4Tegra is installed and no other OpenCV version as far as I can see Should I include something more?

[edit]Here is my CMakeLists.txt

cmake_minimum_required(VERSION 2.8.3)
project(test)

find_package(catkin REQUIRED COMPONENTS
  roscpp
  std_msgs
  cv_bridge
)

include_directories(
  include
  ${catkin_INCLUDE_DIRS}
)

add_executable(test src/test.cpp)
add_dependencies(test ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS} ${PROJECT_NAME}_gen$
target_link_libraries(test
  ${catkin_LIBRARIES}
)

[/edit]

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2017-10-30 15:21:34 -0500

bpinaya gravatar image

Is cv::cuda::GpuMat working from a standard c++ file? I think it could be that you installed OpenCV4Tegra wrong or maybe there is an issue of your CMakeList.txt, would you mind posting it? PS. I used this to build OpenCV4Tegra with no problem at all.

edit flag offensive delete link more

Comments

What do you mean with "a standard c++ file"?

Is the OpenCV installed by default on the TX1 not the OpenCV4Tegra? I did not install a custom OpenCV.

WLemkens gravatar image WLemkens  ( 2017-11-04 12:14:50 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2017-10-29 05:06:06 -0500

Seen: 1,836 times

Last updated: Nov 04 '17