1
0
mirror of https://gitee.com/drabel/LibQQt.git synced 2025-01-04 10:18:44 +08:00

更新qqtframe.h

This commit is contained in:
tianduanrui 2019-09-08 23:53:39 +08:00
parent 5ebd3df8bd
commit 9d57455994
26 changed files with 485 additions and 45 deletions

View File

@ -29,7 +29,7 @@ int main ( int argc, char* argv[] )
w.setMinimumSize ( 420, 720 ); w.setMinimumSize ( 420, 720 );
w.setGeometry ( 0, 0, 420, 720 ); w.setGeometry ( 0, 0, 420, 720 );
moveCenter ( &w ); moveCenter ( &w );
w.setPixmap ( conf_qrc ( "rose.png" ) ); w.setPixmap ( conf_root ( "rose.png" ) );
w.show(); w.show();
#if 0 #if 0

View File

@ -43,7 +43,7 @@ QQtOsdForm::QQtOsdForm ( QWidget* parent ) :
//setWindowFlag ( Qt::WindowSystemMenuHint, true ); //setWindowFlag ( Qt::WindowSystemMenuHint, true );
//setAttribute ( Qt::WA_DeleteOnClose, true ); //setAttribute ( Qt::WA_DeleteOnClose, true );
setPixmap ( conf_qrc ( "rose.png" ) ); setPixmap ( conf_root ( "rose.png" ) );
} }
QQtOsdForm::~QQtOsdForm() QQtOsdForm::~QQtOsdForm()

View File

@ -74,26 +74,32 @@ enum
#define LANG_PATH QString(CONFIG_ROOT + "/lang") #define LANG_PATH QString(CONFIG_ROOT + "/lang")
#if defined (__ANDROIDX86__) #if defined (__ANDROIDX86__)
#define conf_qrc(file) QString("%1/%2").arg("assets:/").arg(file) #define conf_root(file) QString("%1/%2").arg("assets:/").arg(file)
#define conf_res(file) QString("%1/%2").arg("assets:/res").arg(file) #define conf_res(file) QString("%1/%2").arg("assets:/res").arg(file)
#define conf_skin(file) QString("%1/%2").arg("assets:/skin").arg(file) #define conf_skin(file) QString("%1/%2").arg("assets:/skin").arg(file)
#define conf_font(file) QString("%1/%2").arg("assets:/font").arg(file) #define conf_font(file) QString("%1/%2").arg("assets:/font").arg(file)
#define conf_db(file) QString("%1/%2").arg("assets:/db").arg(file) #define conf_db(file) QString("%1/%2").arg("assets:/db").arg(file)
#define conf_lang(file) QString("%1/%2").arg("assets:/lang").arg(file) #define conf_lang(file) QString("%1/%2").arg("assets:/lang").arg(file)
#define conf_conf(file) QString("%1/%2").arg("assets:/conf").arg(file)
#define conf_log(file) QString("%1/%2").arg("assets:/log").arg(file)
#elif defined (__ANDROID__) #elif defined (__ANDROID__)
#define conf_qrc(file) QString("%1/%2").arg("://").arg(file) #define conf_root(file) QString("%1/%2").arg("://").arg(file)
#define conf_res(file) QString("%1/%2").arg("://res").arg(file) #define conf_res(file) QString("%1/%2").arg("://res").arg(file)
#define conf_skin(file) QString("%1/%2").arg("://skin").arg(file) #define conf_skin(file) QString("%1/%2").arg("://skin").arg(file)
#define conf_font(file) QString("%1/%2").arg("://font").arg(file) #define conf_font(file) QString("%1/%2").arg("://font").arg(file)
#define conf_db(file) QString("%1/%2").arg("://db").arg(file) #define conf_db(file) QString("%1/%2").arg("://db").arg(file)
#define conf_lang(file) QString("%1/%2").arg("://lang").arg(file) #define conf_lang(file) QString("%1/%2").arg("://lang").arg(file)
#define conf_conf(file) QString("%1/%2").arg("://conf").arg(file)
#define conf_log(file) QString("%1/%2").arg("://log").arg(file)
#else #else
#define conf_qrc(file) QDir().absoluteFilePath(QString("%1/%2").arg(CONFIG_ROOT).arg(file)) #define conf_root(file) QDir().absoluteFilePath(QString("%1/%2").arg(CONFIG_ROOT).arg(file))
#define conf_res(file) QDir().absoluteFilePath(QString("%1/%2").arg(AV_PATH).arg(file)) #define conf_res(file) QDir().absoluteFilePath(QString("%1/%2").arg(AV_PATH).arg(file))
#define conf_skin(file) QDir().absoluteFilePath(QString("%1/%2").arg(SKIN_PATH).arg(file)) #define conf_skin(file) QDir().absoluteFilePath(QString("%1/%2").arg(SKIN_PATH).arg(file))
#define conf_font(file) QDir().absoluteFilePath(QString("%1/%2").arg(FONT_PATH).arg(file)) #define conf_font(file) QDir().absoluteFilePath(QString("%1/%2").arg(FONT_PATH).arg(file))
#define conf_db(file) QDir().absoluteFilePath(QString("%1/%2").arg(DB_PATH).arg(file)) #define conf_db(file) QDir().absoluteFilePath(QString("%1/%2").arg(DB_PATH).arg(file))
#define conf_lang(file) QDir().absoluteFilePath(QString("%1/%2").arg(LANG_PATH).arg(file)) #define conf_lang(file) QDir().absoluteFilePath(QString("%1/%2").arg(LANG_PATH).arg(file))
#define conf_conf(file) QDir().absoluteFilePath(QString("%1/%2").arg(CONFIG_PATH).arg(file))
#define conf_log(file) QDir().absoluteFilePath(QString("%1/%2").arg(LOG_PATH).arg(file))
#endif #endif
extern QString gUserName; extern QString gUserName;

View File

@ -7,7 +7,7 @@ MainWindow::MainWindow ( QWidget* parent ) :
ui ( new Ui::MainWindow ) ui ( new Ui::MainWindow )
{ {
ui->setupUi ( this ); ui->setupUi ( this );
ui->widget_2->setPixmap ( conf_qrc ( "a.png" ) ); ui->widget_2->setPixmap ( conf_root ( "a.png" ) );
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()

View File

@ -13,29 +13,29 @@ MainWindow::MainWindow ( QWidget* parent ) :
ui ( new Ui::MainWindow ) ui ( new Ui::MainWindow )
{ {
ui->setupUi ( this ); ui->setupUi ( this );
QString svg = QString ( conf_qrc ( "aa.svg" ) ); QString svg = QString ( conf_root ( "aa.svg" ) );
ui->w->setSvgFile ( svg ); ui->w->setSvgFile ( svg );
ui->b0->iconTable() [BTN_NORMAL] = conf_qrc ( "bt_stir.svg" ); ui->b0->iconTable() [BTN_NORMAL] = conf_root ( "bt_stir.svg" );
ui->b0->iconTable() [BTN_HOVER] = conf_qrc ( "bt_stir.svg" ); ui->b0->iconTable() [BTN_HOVER] = conf_root ( "bt_stir.svg" );
ui->b0->iconTable() [BTN_PRESS] = conf_qrc ( "bt_stir_press.svg" ); ui->b0->iconTable() [BTN_PRESS] = conf_root ( "bt_stir_press.svg" );
ui->b0->renderToVariable(); ui->b0->renderToVariable();
ui->c0->iconTable() [BTN_NORMAL] = conf_qrc ( "bt_stir.svg" ); ui->c0->iconTable() [BTN_NORMAL] = conf_root ( "bt_stir.svg" );
ui->c0->iconTable() [BTN_HOVER] = conf_qrc ( "bt_stir.svg" ); ui->c0->iconTable() [BTN_HOVER] = conf_root ( "bt_stir.svg" );
ui->c0->iconTable() [BTN_PRESS] = conf_qrc ( "bt_stir_press.svg" ); ui->c0->iconTable() [BTN_PRESS] = conf_root ( "bt_stir_press.svg" );
ui->c0->renderToVariable(); ui->c0->renderToVariable();
ui->r0->iconTable() [BTN_NORMAL] = conf_qrc ( "bt_stir.svg" ); ui->r0->iconTable() [BTN_NORMAL] = conf_root ( "bt_stir.svg" );
ui->r0->iconTable() [BTN_HOVER] = conf_qrc ( "bt_stir.svg" ); ui->r0->iconTable() [BTN_HOVER] = conf_root ( "bt_stir.svg" );
ui->r0->iconTable() [BTN_PRESS] = conf_qrc ( "bt_stir_press.svg" ); ui->r0->iconTable() [BTN_PRESS] = conf_root ( "bt_stir_press.svg" );
ui->r0->renderToVariable(); ui->r0->renderToVariable();
ui->r1->iconTable() [BTN_NORMAL] = conf_qrc ( "bt_stir.svg" ); ui->r1->iconTable() [BTN_NORMAL] = conf_root ( "bt_stir.svg" );
ui->r1->iconTable() [BTN_HOVER] = conf_qrc ( "bt_stir.svg" ); ui->r1->iconTable() [BTN_HOVER] = conf_root ( "bt_stir.svg" );
ui->r1->iconTable() [BTN_PRESS] = conf_qrc ( "bt_stir_press.svg" ); ui->r1->iconTable() [BTN_PRESS] = conf_root ( "bt_stir_press.svg" );
ui->r1->renderToVariable(); ui->r1->renderToVariable();
ui->p0->setSvgFile ( conf_qrc ( "bk_progress_background.svg" ), ui->p0->setSvgFile ( conf_root ( "bk_progress_background.svg" ),
conf_qrc ( "bk_progress_trunk.svg" ) ); conf_root ( "bk_progress_trunk.svg" ) );
ui->p0->setRange ( 0, 100 ); ui->p0->setRange ( 0, 100 );
ui->p0->setValue ( 60 ); ui->p0->setValue ( 60 );

View File

@ -14,26 +14,6 @@
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
struct buffer_t
{
void* start;
size_t length;
};
struct cap_handle
{
int fd;
int image_size;
struct buffer_t* buffers;
unsigned int nbuffers;
struct cap_param params;
int quit;
unsigned long image_counter;
// v4l2 buffer get/put
struct v4l2_buffer v4lbuf;
int v4lbuf_put; // 0/1
};
static int xioctl ( int fd, int request, void* arg ) static int xioctl ( int fd, int request, void* arg )
{ {
int r; int r;

View File

@ -1,6 +1,18 @@
#ifndef LIBV4L2CAPTURE_H #ifndef LIBV4L2CAPTURE_H
#define LIBV4L2CAPTURE_H #define LIBV4L2CAPTURE_H
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <linux/videodev2.h>
#include <stdlib.h>
#include <assert.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h> #include <string.h>
typedef unsigned int U32; typedef unsigned int U32;
@ -21,7 +33,26 @@ struct cap_param
}; };
/**< capture handle */ /**< capture handle */
struct cap_handle;
struct buffer_t
{
void* start;
size_t length;
};
struct cap_handle
{
int fd;
int image_size;
struct buffer_t* buffers;
unsigned int nbuffers;
struct cap_param params;
int quit;
unsigned long image_counter;
// v4l2 buffer get/put
struct v4l2_buffer v4lbuf;
int v4lbuf_put; // 0/1
};
/** /**
* @brief Open a capture device * @brief Open a capture device

View File

@ -3,7 +3,7 @@
int main ( int argc, char* argv[] ) int main ( int argc, char* argv[] )
{ {
QQtApplication a ( argc, argv ); QApplication a ( argc, argv );
MainWindow w; MainWindow w;
w.show(); w.show();

View File

@ -1,5 +1,7 @@
#include <qqtv4l2videomanager.h> #include <qqtv4l2videomanager.h>
#include <libv4l2capture.h>
#include <linux/videodev2.h> #include <linux/videodev2.h>
QQtV4L2VideoManager::QQtV4L2VideoManager ( QObject* parent ) : QObject ( parent ) QQtV4L2VideoManager::QQtV4L2VideoManager ( QObject* parent ) : QObject ( parent )
@ -10,7 +12,7 @@ QQtV4L2VideoManager::QQtV4L2VideoManager ( QObject* parent ) : QObject ( parent
mDevName = "/dev/video0"; mDevName = "/dev/video0";
mSize = QSize ( 720, 480 ); mSize = QSize ( 720, 480 );
mFormat = V4L2_PIX_FMT_NV21; //NV21? YUV? RGB? mFormat = V4L2_PIX_FMT_YUYV;//V4L2_PIX_FMT_NV21; //NV21? YUV? RGB?
mRate = 10; mRate = 10;
timer = new QTimer ( this ); timer = new QTimer ( this );
@ -41,11 +43,66 @@ void QQtV4L2VideoManager::setVideoRate ( int rate )
mRate = rate; mRate = rate;
} }
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <linux/videodev2.h>
#include <stdlib.h>
#include <assert.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#ifdef ANDROID
#include <android/log.h>
#define logstr(str) __android_log_write(ANDROID_LOG_DEBUG, "QDebug", str);
#else
#define logstr(str)
#endif
void QQtV4L2VideoManager::check_support_fmt()
{
//VIDIOC_ENUM_FMT // 查询,显⽰所有⽀持的格式
printf ( "Checking Device Supported Format......\n" );
struct v4l2_fmtdesc fmtdesc;
fmtdesc.index = 0;
fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
printf ( "Supported Formats:\n" );
while ( ioctl ( handler->fd, VIDIOC_ENUM_FMT, &fmtdesc ) != -1 )
{
QString str = QString ( "%1 %2" ).arg ( fmtdesc.index + 1 ).arg ( ( char* ) fmtdesc.description );
logstr ( str.toLocal8Bit().data() );
printf ( "\t%d.%s\n", fmtdesc.index + 1, fmtdesc.description );
fmtdesc.index++;
}
//检查是否支持格式V4L2_PIX_FMT_MJPEG
struct v4l2_format fmt;
memset ( &fmt, 0, sizeof ( fmt ) );
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_MJPEG;
if ( ioctl ( handler->fd, VIDIOC_TRY_FMT, &fmt ) == -1 && errno == EINVAL )
{
printf ( "not support format V4L2_PIX_FMT_MJPEG!\n" );
}
else
{
printf ( "Do support format V4L2_PIX_FMT_MJPEG!\n" );
}
}
void QQtV4L2VideoManager::startCapture() void QQtV4L2VideoManager::startCapture()
{ {
if ( handler ) if ( handler )
capture_close ( handler ); capture_close ( handler );
struct cap_param param; struct cap_param param;
param.dev_name = mDevName.toLocal8Bit().data(); param.dev_name = mDevName.toLocal8Bit().data();
param.width = mSize.width(); param.width = mSize.width();
@ -53,6 +110,7 @@ void QQtV4L2VideoManager::startCapture()
param.rate = mRate; param.rate = mRate;
param.pixfmt = mFormat; param.pixfmt = mFormat;
handler = capture_open ( param ); handler = capture_open ( param );
check_support_fmt();
pp = ( unsigned char* ) malloc ( param.width * param.height * 3 * sizeof ( char ) ); pp = ( unsigned char* ) malloc ( param.width * param.height * 3 * sizeof ( char ) );
frame = new QImage ( pp, param.width, param.height, QImage::Format_RGB888 ); frame = new QImage ( pp, param.width, param.height, QImage::Format_RGB888 );

View File

@ -10,6 +10,7 @@
#include <libv4l2capture.h> #include <libv4l2capture.h>
#include <QImage> #include <QImage>
/** /**
* @brief The QQtV4L2VideoManager class * @brief The QQtV4L2VideoManager class
* *
@ -27,6 +28,8 @@ public:
void setPixmapFormat ( quint32 format ); void setPixmapFormat ( quint32 format );
void setVideoRate ( int rate ); void setVideoRate ( int rate );
void check_support_fmt ( void );
public slots: public slots:
void startCapture(); void startCapture();
void stopCapture(); void stopCapture();
@ -37,7 +40,7 @@ signals:
protected: protected:
int convert_yuv_to_rgb_pixel ( int y, int u, int v ); int convert_yuv_to_rgb_pixel ( int y, int u, int v );
int convert_yuv_to_rgb_buffer ( unsigned char* yuv, unsigned char* rgb, unsigned int width, int convert_yuv_to_rgb_buffer ( unsigned char* yuv, unsigned char* rgb, unsigned int width,
unsigned int height ); unsigned int height );
private slots: private slots:
void slotGetCapture(); void slotGetCapture();

View File

@ -0,0 +1,24 @@
/*spinbox 抬起样式*/
QTimeEdit::up-button,QDoubleSpinBox::up-button,QSpinBox::up-button {
subcontrol-origin:border;
subcontrol-position:right;
width: 12px;
}
QTimeEdit::down-button,QDoubleSpinBox::down-button,QSpinBox::down-button {
subcontrol-origin:border;
subcontrol-position:left;
width: 12px;
}
/*按钮按下样式*/
QTimeEdit::up-button:pressed,QDoubleSpinBox::up-button:pressed,QSpinBox::up-button:pressed{
subcontrol-origin:border;
subcontrol-position:right;
width: 12px;
}
QTimeEdit::down-button:pressed,QDoubleSpinBox::down-button:pressed,QSpinBox::down-button:pressed,QSpinBox::down-button:pressed{
subcontrol-position:left;
width: 12px;
}

View File

@ -0,0 +1,89 @@
<?xml version="1.0"?>
<manifest package="org.qtproject.example.videotest6" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" android:installLocation="auto">
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="videotest6" android:icon="@drawable/icon">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="videotest6" android:screenOrientation="unspecified" android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<!-- Application arguments -->
<!-- meta-data android:name="android.app.arguments" android:value="arg1 arg2 arg3"/ -->
<!-- Application arguments -->
<meta-data android:name="android.app.lib_name" android:value="videotest6"/>
<meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
<meta-data android:name="android.app.repository" android:value="default"/>
<meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
<meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
<!-- Deploy Qt libs as part of package -->
<meta-data android:name="android.app.bundle_local_qt_libs" android:value="1"/>
<meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/>
<meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/>
<!-- Run with local libs -->
<meta-data android:name="android.app.use_local_qt_libs" android:value="1"/>
<meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
<meta-data android:name="android.app.load_local_libs" android:value="plugins/platforms/android/libqtforandroid.so"/>
<meta-data android:name="android.app.load_local_jars" android:value="jar/QtAndroid.jar:jar/QtAndroid-bundled.jar"/>
<meta-data android:name="android.app.static_init_classes" android:value=""/>
<!-- Messages maps -->
<meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
<meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
<meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
<!-- Messages maps -->
<!-- Splash screen -->
<!-- meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/ -->
<!-- meta-data android:name="android.app.splash_screen_sticky" android:value="true"/ -->
<!-- Splash screen -->
<!-- Background running -->
<!-- Warning: changing this value to true may cause unexpected crashes if the
application still try to draw after
"applicationStateChanged(Qt::ApplicationSuspended)"
signal is sent! -->
<meta-data android:name="android.app.background_running" android:value="false"/>
<!-- Background running -->
<!-- auto screen scale factor -->
<meta-data android:name="android.app.auto_screen_scale_factor" android:value="false"/>
<!-- auto screen scale factor -->
<!-- extract android style -->
<!-- available android:values :
* full - useful QWidget & Quick Controls 1 apps
* minimal - useful for Quick Controls 2 apps, it is much faster than "full"
* none - useful for apps that don't use any of the above Qt modules
-->
<meta-data android:name="android.app.extract_android_style" android:value="full"/>
<!-- extract android style -->
</activity>
<!-- For adding service(s) please check: https://wiki.qt.io/AndroidServices -->
</application>
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="16"/>
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
Remove the comment if you do not require these default permissions. -->
<!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
Remove the comment if you do not require these default features. -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<!-- %%INSERT_PERMISSIONS -->
<!-- %%INSERT_FEATURES -->
<uses-permission android:name="android.permission.ACCESS_CHECKIN_PROPERTIES"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
</manifest>

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

11
test/videotest6/main.cpp Normal file
View File

@ -0,0 +1,11 @@
#include "mainwindow.h"
#include <QQtApplication>
int main ( int argc, char* argv[] )
{
QQtApplication a ( argc, argv );
MainWindow w;
w.show();
return a.exec();
}

View File

@ -0,0 +1,85 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <qqtmsgbox.h>
#include <QMessageBox>
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <linux/videodev2.h>
#include <stdlib.h>
#include <assert.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
static int xioctl ( int fd, int request, void* arg )
{
int r;
do
r = ioctl ( fd, request, arg );
while ( -1 == r && EINTR == errno );
return r;
}
MainWindow::MainWindow ( QWidget* parent ) :
QMainWindow ( parent ),
ui ( new Ui::MainWindow )
{
ui->setupUi ( this );
}
MainWindow::~MainWindow()
{
delete ui;
}
int fd = 0;
void MainWindow::on_pushButton_clicked()
{
fd = ::open ( "/dev/video2", O_RDONLY );
if ( fd < 0 )
{
QMessageBox::warning ( this, "Open Error", "打开设备失败" );
return;
}
printf ( "Checking Device Supported Format......\n" );
struct v4l2_fmtdesc fmtdesc;
fmtdesc.index = 0;
fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
printf ( "Supported Formats:\n" );
while ( ioctl ( fd, VIDIOC_ENUM_FMT, &fmtdesc ) != -1 )
{
QMessageBox::warning ( this, "Supported Format", QString ( "Fmt: %1: %2" ).arg ( fmtdesc.index ).arg ( ( char* ) fmtdesc.description ) );
printf ( "\t%d.%s\n", fmtdesc.index + 1, fmtdesc.description );
fmtdesc.index++;
}
//检查是否支持格式V4L2_PIX_FMT_MJPEG
struct v4l2_format fmt;
memset ( &fmt, 0, sizeof ( fmt ) );
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_MJPEG;
if ( ioctl ( fd, VIDIOC_TRY_FMT, &fmt ) == -1 && errno == EINVAL )
{
QMessageBox::warning ( this, "Try Format", QString ( "不支持MJPEG" ) );
printf ( "not support format V4L2_PIX_FMT_MJPEG!\n" );
}
else
{
QMessageBox::warning ( this, "Try Format", QString ( "支持MJPEG" ) );
printf ( "Do support format V4L2_PIX_FMT_MJPEG!\n" );
}
}
void MainWindow::on_pushButton_2_clicked()
{
::close ( fd );
}

View File

@ -0,0 +1,27 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow ( QWidget* parent = 0 );
~MainWindow();
private slots:
void on_pushButton_clicked();
void on_pushButton_2_clicked();
private:
Ui::MainWindow* ui;
};
#endif // MAINWINDOW_H

View File

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>186</width>
<height>442</height>
</rect>
</property>
<property name="windowTitle">
<string>videotest6</string>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<widget class="QWidget" name="widget" native="true"/>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Start</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>Stop</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>186</width>
<height>17</height>
</rect>
</property>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QStatusBar" name="statusBar"/>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,66 @@
#-------------------------------------------------
#
# Project created by QtCreator 2018-10-06T08:16:10
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = videotest6
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp \
mainwindow.cpp
HEADERS += \
mainwindow.h
FORMS += \
mainwindow.ui
include($${PWD}/../../multi-link/add_base_manager.pri)
#-------------------------------------------------
#用户工程配置
#-------------------------------------------------
add_version(1,0,0,0)
add_deploy()
add_deploy_config($${PWD}/AppRoot)
add_dependent_manager(QQt)
system(touch main.cpp)
#-------------------------------------------------
#用户工程配置
#-------------------------------------------------
equals(QSYS_PRIVATE, macOS) {
CONFIG += app_bundle
}
contains(QSYS_PRIVATE, Android|AndroidX86) {
CONFIG += mobility
MOBILITY =
DISTFILES += \
android/AndroidManifest.xml
ANDROID_PACKAGE_SOURCE_DIR = $${PWD}/android
}
message ($${TARGET} config $${CONFIG})
message ($${TARGET} DEFINE $${DEFINES})
message ($${TARGET} prelink $${QMAKE_PRE_LINK})
message ($${TARGET} postlink $${QMAKE_POST_LINK})