NOOB question
-
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
-
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 ? -
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 -
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-qlabelThis might be interesting in later steps
https://github.com/MicrocontrollersAndMore/OpenCV_3_License_Plate_Recognition_Cpp