Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. I'm trying to connect my web cam in a ROS project on ubuntu mate and Raspberry PI.
Forum Updated to NodeBB v4.3 + New Features

I'm trying to connect my web cam in a ROS project on ubuntu mate and Raspberry PI.

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 197 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alex_Spi13
    wrote on last edited by
    #1

    Hello guys I'm trying to connect a Web cam in a robot project with ROS. When I press the button from main Ui I've no image and I've got this message in terminal.
    QWidget::paintEngine : Should not longer be called.

    Here's the code

    #include "Cameradialog.h"
    #include "ui_Cameradialog.h"
    #include <QCamera>
    #include <QtMultimediaWidgets/QCameraViewfinder>
    #include <QCameraImageCapture>
    #include <QVBoxLayout>
    #include <QMenu>
    #include <QAction>
    #include <QScrollArea>
    
    CameraDialog::CameraDialog(QWidget *parent) :
        QWidget(parent),
        ui(new Ui::CameraDialog)
    {
        ui->setupUi(this);
        // Camera init
        m_Camera = new QCamera(this);
        m_CameraViewFinder = new QCameraViewfinder(this);
        m_CameraImapgeCapture = new QCameraImageCapture(m_Camera, this);
        m_Layout = new QVBoxLayout;
    
        m_Camera->setViewfinder(m_CameraViewFinder);
        m_Layout->addWidget(m_CameraViewFinder);
        m_Layout->setMargin(0);
    
        ui->scrollArea->setLayout(m_Layout);
    
    }
    
    CameraDialog::~CameraDialog()
    {
        delete ui;
        delete m_Camera; delete m_CameraViewFinder;
        delete m_CameraImapgeCapture; delete m_Layout;
    }
    
    void CameraDialog::on_m_CameraStartButon_clicked()
    {
        m_Camera->start();
    }
    
    

    And here's is the CMakeLists.txt if it needed.

    
     ##############################################################################
    # CMake
    ##############################################################################
    
    cmake_minimum_required(VERSION 2.8.0)
    project(Monster_Truck_UI)
    
    set(CMAKE_AUTOUIC ON)
    ##############################################################################
    # Catkin
    ##############################################################################
    
    # qt_build provides the qt cmake glue, roscpp the comms for a default talker
    find_package(catkin REQUIRED COMPONENTS qt_build roscpp)
    include_directories(${catkin_INCLUDE_DIRS})
    # Use this to define what the package will export (e.g. libs, headers).
    # Since the default here is to produce only a binary, we don't worry about
    # exporting anything. 
    catkin_package()
    
    ##############################################################################
    # Qt Environment
    ##############################################################################
    
    # this comes from qt_build's qt-ros.cmake which is automatically 
    # included via the dependency call in package.xml
    
    ##############################################################################
    # Sections
    ##############################################################################
    
    
    set(CMAKE_AUTOMOC ON)
    
    find_package(Qt5 REQUIRED COMPONENTS
                    Core
                    Gui
                    Widgets
                    Multimedia
                    MultimediaWidgets
                )
    
    QT5_ADD_RESOURCES(QT_RESOURCES_CPP ${QT_RESOURCES})
    QT5_WRAP_UI(QT_FORMS_HPP ${QT_FORMS})##############################################################################
    # Sources
    ##############################################################################
    include_directories(
        ${Qt5Core_INCLUDE_DIRS}
        ${Qt5Gui_INCLUDE_DIRS}
        ${Qt5Widgets_INCLUDE_DIRS}
         ${Qt5Multimedia_INCLUDE_DIRS}
        )
    
    set(QT_SOURCES
        src/main.cpp
        src/mainwindow.cpp
        src/mainwindow.h
        src/mainwindow.ui
        src/Events/keyboard_events.h
    	
    	src/Manual_Window/manual_window.cpp
    	src/Manual_Window/manual_window.h
    	src/Manual_Window/manual_window.ui
    
            src/Camera_Window/Cameradialog.h
            src/Camera_Window/Cameradialog.cpp
            src/Camera_Window/Cameradialog.ui
    
        #ROS SRC
    	src/ROS_src/_ros.h
    	src/ROS_src/_ros.cpp
            src/ROS_src/rviz.h
            src/ROS_src/rviz.cpp
        )
    
    ##############################################################################
    # Binaries
    ##############################################################################
    
    add_executable(Monster_Truck_UI ${QT_SOURCES} ${QT_RESOURCES_CPP} ${QT_FORMS_HPP} ${QT_MOC_HPP})
    target_link_libraries(Monster_Truck_UI ${QT_LIBRARIES} ${catkin_LIBRARIES}
     Qt5::Core  Qt5::Widgets Qt5::Multimedia Qt5::MultimediaWidgets)
    
    install(TARGETS Monster_Truck_UI RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
    
    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      What version of Qt 5.x?

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved