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. NOOB question
Forum Updated to NodeBB v4.3 + New Features

NOOB question

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 990 Views 1 Watching
  • 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.
  • XmodptX Offline
    XmodptX Offline
    Xmodpt
    wrote on last edited by
    #1

    Hello everyone

    i am new both to C++ an QT and i have a noob question.

    I have an app what opens a widget window with my IP camera image,

    Q: how to i get if to open in my UI ? i have a label in my UI named lblStream.

    #include "widget.h"
    #include "ui_widget.h"

    #include <iostream>
    #include <string.h>
    #include "opencv2/core/core.hpp"
    #include "opencv2/opencv.hpp"
    #include "opencv2/videoio/videoio.hpp"
    #include "opencv2/highgui/highgui.hpp"
    #include "opencv2/video.hpp"
    #include "opencv2/imgproc/imgproc.hpp"

    using namespace cv;
    using namespace std;

    Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
    {
    ui->setupUi(this);
    this->setWindowState(Qt::WindowMaximized);

    //################# open the default WEBCAM FOR TESTING
    //   VideoCapture cap(0);
    //    if(!cap.isOpened())  // check if we succeeded
    //        cap.set(CV_CAP_PROP_BUFFERSIZE, 3); // internal buffer will now store only 3 frames
    //       delete ui;
    //#################################################
    //################# open the default IP camera
        VideoCapture cap("rtsp://admin:admin54321@192.168.1.101/Streaming/Channels/1");
        if(!cap.isOpened())  // check if we succeeded
           cap.set(CV_CAP_PROP_BUFFERSIZE, 5); // internal buffer will now store only 3 frames
             delete ui;
    //#################################################
    
    //################ Define Edges ##################
        Mat edges;
        namedWindow("edges",1);
        for(;;)
        {
            Mat frame;
            cap >> frame; // get a new frame from cameraws
            cvtColor(frame, edges, CV_BGR2GRAY); // converts to GrayScale
            //GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5);
            //Canny(edges, edges, 0, 30, 3);
            imshow("edges", edges);
            if(waitKey(30) >= 0) break;
    
        }
        // the camera will be deinitialized automatically in VideoCapture destructor
         delete ui;
    

    }

    Widget::~Widget()
    {

    delete ui;
    

    }

    King regards to all

    Npires

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi and welcome to the forums
      You can easy get that widget inside a mainwindow using promotion.
      http://doc.qt.io/qt-5/designer-using-custom-widgets.html
      (basically, you just place a QWidget on the UI file, right click it select promote and tell the name and .h file of your own widget. Press the Add button and then promote and when you runs its magically your own widget. )

      But is it really the widget u see ?
      imshow seems to be an openCV call and it creates its own window ?

      XmodptX 1 Reply Last reply
      2
      • mrjjM mrjj

        Hi and welcome to the forums
        You can easy get that widget inside a mainwindow using promotion.
        http://doc.qt.io/qt-5/designer-using-custom-widgets.html
        (basically, you just place a QWidget on the UI file, right click it select promote and tell the name and .h file of your own widget. Press the Add button and then promote and when you runs its magically your own widget. )

        But is it really the widget u see ?
        imshow seems to be an openCV call and it creates its own window ?

        XmodptX Offline
        XmodptX Offline
        Xmodpt
        wrote on last edited by Xmodpt
        #3

        @mrjj

        Hello m8 thank you for your quick reply.

        "imshow seems to be an openCV call and it creates its own window ?"
        It's true, it pops up it's own windows but what i wanted was for it to open inside a form UI,

        My general idea is to make my own ANPR system. (baby steps)
        the app shoud not have any controls or buttons as it is to run as a standalone system.

        what is your suggestion ?

        Regards
        NPires

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #4

          Hi
          The post i have seen regarding openCV often uses a QImage to display
          the images. I assume you can do the same.
          http://amin-ahmadi.com/2015/12/16/how-to-display-a-mat-image-in-qt/
          https://stackoverflow.com/questions/11543298/qt-opencv-displaying-images-on-qlabel

          This might be interesting in later steps
          https://github.com/MicrocontrollersAndMore/OpenCV_3_License_Plate_Recognition_Cpp

          1 Reply Last reply
          2

          • Login

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