資源簡介
是基于嵌入式linux下QT開發的 Camera攝像頭采集視頻源碼,并且源碼里面最重要還有一份QT界面的控件說明文檔等等,源碼經測試,直接可編譯使用

代碼片段和文件信息
#include?“camera.h“
#include?“ui_camera.h“
#include?
#include?
#include?
#include?
#include?
#include?
static?int?fd?=?-1;
struct?buffer
{
????void?*??start;
????size_t??length;
};
struct?buffer?*???????buffers?=?NULL;
static?unsigned?int???n_buffers?=?0;
static?unsigned?int???width?=?800;
static?unsigned?int???height?=?480;
static?char*?deviceName?=?“/dev/video0“;
char?image_buf[1536000+54];
unsigned?char?bmp_h[]?=
{
????????????????0x420x4d????????????//BM
????????????????0x420x700x170x00??//?172000+66
????????????????0x000x000x000x00
????????????????0x360x000x000x00??//bmp_data?offset
????????????????0x280x000x000x00
????????????????0x200x030x000x00???//width
????????????????0xE00x010x000x00???//hieght
????????????????0x010x00
????????????????0x200x00?????????????//32bit
????????????????0x000x000x000x00
????????????????0x000x700x170x00??//bmp_data?size
????????????????0x000x000x000x00
????????????????0x000x000x000x00
????????????????0x000x000x000x00
????????????????0x000x000x000x00
};
Camera::Camera(QWidget?*parent)?:
????QWidget(parent)
????ui(new?Ui::Camera)
{
??????ui->setupUi(this);
??????timer?=?new?QTimer;
??????this->imageWidget?=?new?ImageWidget(this);
??????this->imageWidget->setBackgroundRole(QPalette::Dark);
??????this->imageWidget->setSizePolicy(QSizePolicy::Ignored?QSizePolicy::Ignored);
??????this->imageWidget->setobjectName(QString::fromUtf8(“imageWidget“));
??????this->imageWidget->setGeometry(QRect(5?50?491?371));
??????connect(this->timer?SIGNAL(timeout())?this?SLOT(up_date()));
??????deviceOpen();
??????deviceInit();
??????captureStart();
}
Camera::~Camera()
{
??????delete?ui;
}
void?Camera::closeEvent(QCloseEvent?*event)
{
????????deviceUninit();
????????event->accept();??//exit
}
void?deviceOpen(void)
{
???????fd?=?open(deviceName?O_RDWR?|?O_NONBLOCK?0);
???????if?(-1?==?fd)
???????{
????????????QMessageBox::about(NULL?“About“?“camera?open?error“);
????????????exit(EXIT_FAILURE);
???????}
}
/*??initialize?device*/
void?deviceInit(void)
{
????struct?v4l2_capability?cap;
????struct?v4l2_cropcap?cropcap;
????struct?v4l2_crop?crop;
????struct?v4l2_format?fmt;
????unsigned?int?min;
?????if?(-1?==?xioctl(fd?VIDIOC_QUERYCAP?&cap))
?????{
????????????if?(EINVAL?==?errno)
????????????{
?????????????????QMessageBox::about(NULL“Information““?no?V4L2?device“);
?????????????????exit(EXIT_FAILURE);
????????????}
???????????else
????????????{
?????????????????errno_exit(“VIDIOC_QUERYCAP“);
????????????}
??????}
??????if?(!(cap.capabilities?&?V4L2_CAP_VIDEO_CAPTURE))
??????{
?????????????QMessageBox::about(NULL“Information““?no?video?capture?device“);
?????????????exit(EXIT_FAILURE);
??????}
??????struct?v4l2_input?input;
??????input.index?=?0;
??????if?(?ioctl(fd?VIDIOC_ENUMINPUT?&input)?!=?0)
??????{
????????????QMessageBox::about(NULL“Information““set?input?error“);
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????10241??2013-07-30?14:57??Camera\camera.cpp
?????文件???????1009??2013-07-30?14:48??Camera\camera.h
?????文件????????340??2013-07-30?14:21??Camera\Camera.pro
?????文件??????44361??2013-07-31?10:40??Camera\Camera.pro.user
?????文件????????968??2013-07-13?13:33??Camera\camera.ui
?????文件????????961??2013-07-30?14:58??Camera\imagewidget.cpp
?????文件????????500??2012-05-04?20:02??Camera\imagewidget.h
?????文件????????278??2013-07-13?11:03??Camera\main.cpp
?????文件????1552031??2013-08-05?11:31??Camera\Qt4.7測試程序使用說明.pdf
?????目錄??????????0??2016-11-25?10:16??Camera
-----------?---------??----------?-----??----
??????????????1610689????????????????????10
評論
共有 條評論