Opencv+qt+beaglebone to get the camera data.

Source: Internet
Author: User

Recently in the study of OpenCV.

The OpenCV gets the camera data debug successfully.

A simple test code

Mainwindow.h

#ifndef Mainwindow_h#defineMainwindow_h#include<QMainWindow>#include<QLabel>#include<QGridLayout>#include<QPushButton>#include<QComboBox>#include<QImage>//#include <core.hpp>//#include #include #include<cv.h>classMainWindow: Publicqmainwindow{Q_object Public: MainWindow (); ~MainWindow ();Private: Qwidget*MainWindow; Qgridlayout*mainlayout; Qpushbutton*Buttonstart; Qpushbutton*Buttonstop; Qlabel*Picturecamera; Qlabel*pictureprocess; Cvcapture*pcapture; Iplimage*Pimage; voidPaintEvent (Qpaintevent *Event);PrivateSlots:voidStartvideo (); voidStopvideo ();};#endif

MAINWINDOW.C 艹 ~

#include"mainwindow.h"#include<QPainter>#include<iostream>#include<sstream>#include<math.h>using namespacestd; MainWindow:: MainWindow () {MainWindow=NewQwidget;  This-Setcentralwidget (MainWindow); Buttonstart=NewQpushbutton ("START"); Buttonstart-Setsizepolicy (qsizepolicy::fixed,qsizepolicy::fixed); Buttonstop=NewQpushbutton ("STOP"); Buttonstop-Setsizepolicy (qsizepolicy::fixed,qsizepolicy::fixed); Picturecamera=NewQlabel (); Pictureprocess=NewQlabel (); Pcapture= Cvcreatecameracapture (0); Pimage=Cvqueryframe (pcapture); Mainlayout=Newqgridlayout; Mainlayout->addwidget (Buttonstart,0,0,1,1); Mainlayout->addwidget (Buttonstop,0,1,1,1); Mainlayout->addwidget (Picturecamera,1,0,5,5); Mainlayout->addwidget (Pictureprocess,1,5,5,5); MainWindow-setlayout (mainlayout); Qobject::connect (Buttonstart,signal (clicked ()), This, SLOT (Startvideo ())); Qobject::connect (Buttonstop,signal (clicked ()), This, SLOT (Stopvideo ()));  This->setwindowtitle ("beaglebone OpenCV test~");  This->resize (Qsize ( -, -)); }mainwindow::~MainWindow () {cvreleasecapture (&pcapture); MainWindow-Deletelater (); Mainlayout-Deletelater (); Buttonstart-Deletelater (); Buttonstop-Deletelater (); Picturecamera-Deletelater (); Pictureprocess-deletelater ();}voidMainwindow::startvideo () {pimage=Cvqueryframe (pcapture); Qimage ShowImage ((ConstUchar *) pimage->imagedata,pimage->width,pimage->height,qimage::format_rgb888); Picturecamera-Setpixmap (Qpixmap::fromimage (ShowImage));}voidMainwindow::stopvideo () {}voidMainWindow::p aintevent (Qpaintevent *Event){}

MAIN.C 艹

#include <QApplication><QFont>"mainwindow.h"int Main (int argc,Char* argv[]) {    qapplication app (ARGC,ARGV);    MainWindow Mywindow;    Mywindow.show ();     return app.exec ();}

Effect

The

Opencv+qt+beaglebone gets the camera data.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.