更新qqtframe.h
@ -29,7 +29,7 @@ int main ( int argc, char* argv[] )
|
||||
w.setMinimumSize ( 420, 720 );
|
||||
w.setGeometry ( 0, 0, 420, 720 );
|
||||
moveCenter ( &w );
|
||||
w.setPixmap ( conf_qrc ( "rose.png" ) );
|
||||
w.setPixmap ( conf_root ( "rose.png" ) );
|
||||
w.show();
|
||||
|
||||
#if 0
|
||||
|
@ -43,7 +43,7 @@ QQtOsdForm::QQtOsdForm ( QWidget* parent ) :
|
||||
//setWindowFlag ( Qt::WindowSystemMenuHint, true );
|
||||
//setAttribute ( Qt::WA_DeleteOnClose, true );
|
||||
|
||||
setPixmap ( conf_qrc ( "rose.png" ) );
|
||||
setPixmap ( conf_root ( "rose.png" ) );
|
||||
}
|
||||
|
||||
QQtOsdForm::~QQtOsdForm()
|
||||
|
@ -74,26 +74,32 @@ enum
|
||||
#define LANG_PATH QString(CONFIG_ROOT + "/lang")
|
||||
|
||||
#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_skin(file) QString("%1/%2").arg("assets:/skin").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_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__)
|
||||
#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_skin(file) QString("%1/%2").arg("://skin").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_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
|
||||
#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_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_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_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
|
||||
|
||||
extern QString gUserName;
|
||||
|
@ -7,7 +7,7 @@ MainWindow::MainWindow ( QWidget* parent ) :
|
||||
ui ( new Ui::MainWindow )
|
||||
{
|
||||
ui->setupUi ( this );
|
||||
ui->widget_2->setPixmap ( conf_qrc ( "a.png" ) );
|
||||
ui->widget_2->setPixmap ( conf_root ( "a.png" ) );
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
|
@ -13,29 +13,29 @@ MainWindow::MainWindow ( QWidget* parent ) :
|
||||
ui ( new Ui::MainWindow )
|
||||
{
|
||||
ui->setupUi ( this );
|
||||
QString svg = QString ( conf_qrc ( "aa.svg" ) );
|
||||
QString svg = QString ( conf_root ( "aa.svg" ) );
|
||||
ui->w->setSvgFile ( svg );
|
||||
|
||||
ui->b0->iconTable() [BTN_NORMAL] = conf_qrc ( "bt_stir.svg" );
|
||||
ui->b0->iconTable() [BTN_HOVER] = conf_qrc ( "bt_stir.svg" );
|
||||
ui->b0->iconTable() [BTN_PRESS] = conf_qrc ( "bt_stir_press.svg" );
|
||||
ui->b0->iconTable() [BTN_NORMAL] = conf_root ( "bt_stir.svg" );
|
||||
ui->b0->iconTable() [BTN_HOVER] = conf_root ( "bt_stir.svg" );
|
||||
ui->b0->iconTable() [BTN_PRESS] = conf_root ( "bt_stir_press.svg" );
|
||||
ui->b0->renderToVariable();
|
||||
|
||||
ui->c0->iconTable() [BTN_NORMAL] = conf_qrc ( "bt_stir.svg" );
|
||||
ui->c0->iconTable() [BTN_HOVER] = conf_qrc ( "bt_stir.svg" );
|
||||
ui->c0->iconTable() [BTN_PRESS] = conf_qrc ( "bt_stir_press.svg" );
|
||||
ui->c0->iconTable() [BTN_NORMAL] = conf_root ( "bt_stir.svg" );
|
||||
ui->c0->iconTable() [BTN_HOVER] = conf_root ( "bt_stir.svg" );
|
||||
ui->c0->iconTable() [BTN_PRESS] = conf_root ( "bt_stir_press.svg" );
|
||||
ui->c0->renderToVariable();
|
||||
ui->r0->iconTable() [BTN_NORMAL] = conf_qrc ( "bt_stir.svg" );
|
||||
ui->r0->iconTable() [BTN_HOVER] = conf_qrc ( "bt_stir.svg" );
|
||||
ui->r0->iconTable() [BTN_PRESS] = conf_qrc ( "bt_stir_press.svg" );
|
||||
ui->r0->iconTable() [BTN_NORMAL] = conf_root ( "bt_stir.svg" );
|
||||
ui->r0->iconTable() [BTN_HOVER] = conf_root ( "bt_stir.svg" );
|
||||
ui->r0->iconTable() [BTN_PRESS] = conf_root ( "bt_stir_press.svg" );
|
||||
ui->r0->renderToVariable();
|
||||
ui->r1->iconTable() [BTN_NORMAL] = conf_qrc ( "bt_stir.svg" );
|
||||
ui->r1->iconTable() [BTN_HOVER] = conf_qrc ( "bt_stir.svg" );
|
||||
ui->r1->iconTable() [BTN_PRESS] = conf_qrc ( "bt_stir_press.svg" );
|
||||
ui->r1->iconTable() [BTN_NORMAL] = conf_root ( "bt_stir.svg" );
|
||||
ui->r1->iconTable() [BTN_HOVER] = conf_root ( "bt_stir.svg" );
|
||||
ui->r1->iconTable() [BTN_PRESS] = conf_root ( "bt_stir_press.svg" );
|
||||
ui->r1->renderToVariable();
|
||||
|
||||
ui->p0->setSvgFile ( conf_qrc ( "bk_progress_background.svg" ),
|
||||
conf_qrc ( "bk_progress_trunk.svg" ) );
|
||||
ui->p0->setSvgFile ( conf_root ( "bk_progress_background.svg" ),
|
||||
conf_root ( "bk_progress_trunk.svg" ) );
|
||||
ui->p0->setRange ( 0, 100 );
|
||||
ui->p0->setValue ( 60 );
|
||||
|
||||
|
@ -14,26 +14,6 @@
|
||||
#include <unistd.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 )
|
||||
{
|
||||
int r;
|
||||
|
@ -1,6 +1,18 @@
|
||||
#ifndef 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>
|
||||
|
||||
typedef unsigned int U32;
|
||||
@ -21,7 +33,26 @@ struct cap_param
|
||||
};
|
||||
|
||||
/**< 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
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
int main ( int argc, char* argv[] )
|
||||
{
|
||||
QQtApplication a ( argc, argv );
|
||||
QApplication a ( argc, argv );
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include <qqtv4l2videomanager.h>
|
||||
|
||||
#include <libv4l2capture.h>
|
||||
|
||||
#include <linux/videodev2.h>
|
||||
|
||||
QQtV4L2VideoManager::QQtV4L2VideoManager ( QObject* parent ) : QObject ( parent )
|
||||
@ -10,7 +12,7 @@ QQtV4L2VideoManager::QQtV4L2VideoManager ( QObject* parent ) : QObject ( parent
|
||||
|
||||
mDevName = "/dev/video0";
|
||||
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;
|
||||
|
||||
timer = new QTimer ( this );
|
||||
@ -41,11 +43,66 @@ void QQtV4L2VideoManager::setVideoRate ( int 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()
|
||||
{
|
||||
if ( handler )
|
||||
capture_close ( handler );
|
||||
|
||||
|
||||
struct cap_param param;
|
||||
param.dev_name = mDevName.toLocal8Bit().data();
|
||||
param.width = mSize.width();
|
||||
@ -53,6 +110,7 @@ void QQtV4L2VideoManager::startCapture()
|
||||
param.rate = mRate;
|
||||
param.pixfmt = mFormat;
|
||||
handler = capture_open ( param );
|
||||
check_support_fmt();
|
||||
|
||||
pp = ( unsigned char* ) malloc ( param.width * param.height * 3 * sizeof ( char ) );
|
||||
frame = new QImage ( pp, param.width, param.height, QImage::Format_RGB888 );
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <libv4l2capture.h>
|
||||
#include <QImage>
|
||||
|
||||
|
||||
/**
|
||||
* @brief The QQtV4L2VideoManager class
|
||||
* 单个视频设备采集器
|
||||
@ -27,6 +28,8 @@ public:
|
||||
void setPixmapFormat ( quint32 format );
|
||||
void setVideoRate ( int rate );
|
||||
|
||||
void check_support_fmt ( void );
|
||||
|
||||
public slots:
|
||||
void startCapture();
|
||||
void stopCapture();
|
||||
@ -37,7 +40,7 @@ signals:
|
||||
protected:
|
||||
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,
|
||||
unsigned int height );
|
||||
unsigned int height );
|
||||
|
||||
private slots:
|
||||
void slotGetCapture();
|
||||
|
24
test/videotest6/AppRoot/skin/default.qss
Normal 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;
|
||||
}
|
89
test/videotest6/android/AndroidManifest.xml
Normal 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>
|
BIN
test/videotest6/android/res/drawable-hdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
test/videotest6/android/res/drawable-hdpi/icon.png
Normal file
After Width: | Height: | Size: 82 KiB |
BIN
test/videotest6/android/res/drawable-ldpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
test/videotest6/android/res/drawable-ldpi/icon.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
test/videotest6/android/res/drawable-mdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 6.0 KiB |
BIN
test/videotest6/android/res/drawable-mdpi/icon.png
Normal file
After Width: | Height: | Size: 48 KiB |
BIN
test/videotest6/android/res/drawable-xhdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 48 KiB |
After Width: | Height: | Size: 82 KiB |
11
test/videotest6/main.cpp
Normal 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();
|
||||
}
|
85
test/videotest6/mainwindow.cpp
Normal 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 );
|
||||
}
|
27
test/videotest6/mainwindow.h
Normal 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
|
60
test/videotest6/mainwindow.ui
Normal 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>
|
66
test/videotest6/videotest6.pro
Normal 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})
|