硬件

Point Gray Camera

型号:FL3-U3-13S2C-CS

参数

Sony IMX035 CMOS, 1/3", 3.63 µm
Rolling Shutter
1328x1048 at 120 FPS

USB3.0

系统及环境

Windows 7 64bit

Qt 5.1

驱动:FlyCapture v2.5 Release 4 - Windows 64bit

硬件连接

将相机直接接到电脑的USB3.0接口上就可以了。

程序功能

调用摄像头拍照,并在窗口中显示结果拍照结果。

开发的过程中主要是参考官方的文档,在sdk安装的文件夹里就有。

代码清单

代码结构

很简单,就一个类。

首先要在.pro文件中包含头文件和库

INCLUDEPATH += "C:/Program Files/Point Grey Research/FlyCapture2/include"

LIBS += "C:\Program Files\Point Grey Research\FlyCapture2\lib64\FlyCapture2.lib"

main.cpp

#include "mainwindow.h"
#include <QApplication> int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}

初始化一个MainWindow,然后显示,没什么好说的。

mainwindows.h

#ifndef MAINWINDOW_H
#define MAINWINDOW_H #include <QMainWindow>
#include <FlyCapture2.h>
#include <iostream>
#include <QLabel>
#include <QAction>
#include <QStatusBar>
#include <QMessageBox>
#include <QMenu>
#include <QMenuBar>
using namespace std;
using namespace FlyCapture2;
class MainWindow : public QMainWindow
{
Q_OBJECT public:
MainWindow(QWidget *parent = 0);
void printCameraInfo();
~MainWindow();
private:
QLabel *imageLabel;
QMenu *operationMenu;
QMenu *aboutMenu;
QMenu *cameraMenu;
QAction *startAction;
QAction *stopAction;
QAction *aboutAction;
QAction *cameraInfoAction;
QLabel *msgLabel;
QLabel *about; void createActions();
void createMenus();
void printError(Error e);
void getCameraInfo(); PGRGuid guid;
Error error;
Camera cam;
CameraInfo camInfo; public slots:
void slotAbout();
int slotStart();
void slotStop();
void slotShowCameraInfo(); }; #endif // MAINWINDOW_H

首先要包含 FlyCapture2.h 这个头文件,然后定义好窗体的menu,action等等,还有操作相机的几个相关的私有成员。

main.cpp

#include "mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
this->setGeometry(100,100,1000,768);
this->setWindowTitle(tr("FlyCapture View")); //状态栏设定
msgLabel=new QLabel;
msgLabel->setMinimumSize(msgLabel->sizeHint());
this->statusBar()->addWidget(msgLabel); this->createActions();
this->createMenus(); imageLabel = new QLabel;
imageLabel->setBackgroundRole(QPalette::Base);
imageLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
imageLabel->setScaledContents(true); QPixmap image(":/images/images/monster.png");
imageLabel->setPixmap(image);
this->setCentralWidget(imageLabel); //Initialization of camera
BusManager busMgr; error = busMgr.GetCameraFromIndex(0, &guid);
if (error != PGRERROR_OK)
{
printError( error );
//return -1;
} const int k_numImages = 10; // Connect to a camera
error = cam.Connect(&guid);
if (error != PGRERROR_OK)
{
printError( error );
// return -1;
}
// Get the camera information error = cam.GetCameraInfo(&camInfo);
if (error != PGRERROR_OK)
{
printError( error );
//return -1;
} } MainWindow::~MainWindow()
{ } void MainWindow::createActions()
{
this->aboutAction = new QAction(tr("&About"), this);
this->aboutAction->setStatusTip(tr("About author."));
this->connect(aboutAction, SIGNAL(triggered()), this, SLOT(slotAbout())); this->startAction = new QAction(tr("&Start"), this);
this->startAction->setStatusTip(tr("Start capture."));
this->connect(startAction, SIGNAL(triggered()), this, SLOT(slotStart())); this->stopAction = new QAction(tr("&Stop"), this);
this->stopAction->setStatusTip(tr("Stop capture."));
this->connect(stopAction, SIGNAL(triggered()), this, SLOT(slotStop())); this->cameraInfoAction = new QAction(tr("&CameraInfo"), this);
this->cameraInfoAction->setStatusTip(tr("Camera Information."));
this->connect(cameraInfoAction, SIGNAL(triggered()), this, SLOT(slotShowCameraInfo())); } void MainWindow::createMenus()
{
this->operationMenu = this->menuBar()->addMenu(tr("&Operation"));
this->operationMenu->addAction(startAction);
this->operationMenu->addAction(stopAction); this->aboutMenu = this->menuBar()->addMenu(tr("&About"));
this->aboutMenu->addAction(aboutAction); this->cameraMenu = this->menuBar()->addMenu(tr("&Camera"));
this->cameraMenu->addAction(cameraInfoAction);
} void MainWindow::slotAbout()
{
QMessageBox msg(this);
msg.setWindowTitle("About");
msg.setText(tr("Version:1.0 Author:silangquan@gmail.com"));
msg.exec();
} int MainWindow::slotStart()
{ // Start capturing images
error = cam.StartCapture();
if (error != PGRERROR_OK)
{
printError( error );
return -1;
} Image rawImage; error = cam.RetrieveBuffer( &rawImage );
if (error != PGRERROR_OK)
{
printError( error );
// continue;
} // Create a converted image
Image convertedImage; // Convert the raw image
error = rawImage.Convert( PIXEL_FORMAT_RGB, &convertedImage );
if (error != PGRERROR_OK)
{
printError( error );
return -1;
} // Save the image. If a file format is not passed in, then the file
// extension is parsed to attempt to determine the file format.
error = convertedImage.Save( "Test.jpg");
if (error != PGRERROR_OK)
{
printError( error );
return -1;
}
// } // Stop capturing images
error = cam.StopCapture();
if (error != PGRERROR_OK)
{
printError( error );
return -1;
} // Disconnect the camera
error = cam.Disconnect();
if (error != PGRERROR_OK)
{
printError( error );
return -1;
} QPixmap image("Test.jpg");
imageLabel->setPixmap(image);
cout<<"Captured!"<<endl;
return 0; } void MainWindow::slotStop()
{
cout<<"Stop!"<<endl;
} void MainWindow::slotShowCameraInfo()
{
QMessageBox msg(this);
msg.setWindowTitle("Camera Informations");
msg.setText(QString("Serial number - %1\nCamera model - %2\nCamera vendor - %3\nSensor - %4\nResolution - %5\nFirmware version - %6\nFirmware build time - %7\n\n")
.arg(camInfo.serialNumber).arg(camInfo.modelName).arg(camInfo.vendorName).arg(camInfo.sensorInfo).arg(camInfo.sensorResolution)
.arg(camInfo.firmwareVersion).arg(camInfo.firmwareBuildTime)); msg.exec();
} void MainWindow::printError(Error e)
{
e.PrintErrorTrace();
}

主要是函数,槽,界面布局的实现。

最终效果:

源码下载

基于Qt的图像采集系统的更多相关文章

  1. 一、基于Qt的图像矩形区域改色

    Qt环境下图像的打开和涂色 一.设计目标 能够在 Qt QtCreator 环境下打开常用图像格式文件,诸如 bmp.jpg.png 图像等,然后将他们转化为 Qt 中的 QImage 类,并进行矩形 ...

  2. 基础的基于QT的图像查看程序

    代码来自<QT5.9c++开发指南>,因为实现了图片的遍历显示,对于将来编写ImageShop一类的图像程序来说将非常有用(这个程序目前存在一定问题,在研究过程中进行解决) 一.基本功能 ...

  3. 基于Xilinx FPGA的视频图像采集系统

    本篇要分享的是基于Xilinx FPGA的视频图像采集系统,使用摄像头采集图像数据,并没有用到SDRAM/DDR.这个工程使用的是OV7670 30w像素摄像头,用双口RAM做存储,显示窗口为320x ...

  4. 基于FPGA的线阵CCD实时图像采集系统

    基于FPGA的线阵CCD实时图像采集系统 2015年微型机与应用第13期 作者:章金敏,张 菁,陈梦苇2016/2/8 20:52:00 关键词: 实时采集 电荷耦合器件 现场可编程逻辑器件 信号处理 ...

  5. 基于AXI VDMA的图像采集系统

    基于AXI VDMA的图像采集系统 转载 2017年04月18日 17:26:43 标签: framebuffer / AXIS / AXI VDMA 2494 本课程将对Xilinx提供的一款IP核 ...

  6. 基于SDRAM的视频图像采集系统

    本文是在前面设计好的简易SDRAM控制器的基础上完善,逐步实现使用SDRAM存储视频流数据,实现视频图像采集系统,CMOS使用的是OV7725. SDRAM控制器的完善 1. 修改SDRAM的时钟到1 ...

  7. 基于QT的一个简易的安防

    工程描述 opencv2.4.8 QT5 背景建模后,当有异物入侵时,把入侵的帧写到视频文件 使用BackgroundSubtractorMOG2背景建模 程序基于QT对话框 .pro #------ ...

  8. 基于QT的webkit与ExtJs开发CB/S结构的企业应用管理系统

      一:源起       1.何为CB/S的应用程序       C/S结构的应用程序,是客户端/服务端形式的应用程序,这种应用程序要在客户电脑上安装一个程序,客户使用这个程序与服务端通信,完成一定的 ...

  9. 基于clahe的图像去雾

    基于clahe的图像去雾     通过阅读一些资料,我了解到clahe算法对图像去雾有所价值,正好opencv中有了实现,拿过来看一看.   但是现在实现的效果还是有所差异 #);    clahe] ...

随机推荐

  1. Keil MDK下如何设置非零初始化变量

    一些工控产品,当系统复位后(非上电复位),可能要求保持住复位前RAM中的数据,用来快速恢复现场,或者不至于因瞬间复位而重启现场设备.而keil mdk在默认情况下,任何形式的复位都会将RAM区的非初始 ...

  2. Mozilla推荐的CSS书写顺序

    //显示属性displaylist-stylepositionfloatclear //自身属性widthheightmarginpaddingborderbackground //文本属性color ...

  3. logstash 根据type 判断输出

    # 更多ELK资料请访问 http://devops.taobao.com 一.配置前需要注意: 1.Use chmod to modify nginx log file privilege. E.g ...

  4. 大型项目使用Automake/Autoconf完成编译配置

    http://www.cnblogs.com/xf-linux-arm-java-android/p/3590770.htmlhttp://blog.csdn.net/zengraoli/articl ...

  5. C语言入门(15)——结构体与数据抽象

    大多数的计算机运算是对现实世界的模拟,如果想用计算机来模拟现实世界需要用到数据抽象的方法.所谓抽象是从实际的人.物.事和概念中抽取所关心的共同特征,,忽略非本质的细节,吧这些特征用各种概念精确的加以描 ...

  6. 将Linux下编译的warning警告信息输出到文件中[整理笔记]

    Linux中,脚本语言环境中,即你用make xxx即其他一些普通linux命令,比如ls,find等,不同的数字,代表不同的含义: 数字 含义 标准叫法0 标准输入  stdin = standar ...

  7. poj3673---双重for循环

    #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX 15 int main ...

  8. 【HDU】1717 小数化分数2 ——计数原理

    小数化分数2 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Subm ...

  9. Backward Digit Sums(暴力)

    Backward Digit Sums Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5664   Accepted: 32 ...

  10. linux 命令之 uptime

    uptime 命令是用来查询linux系统负载的. 命令格式 uptime [OPTION] -V 显示版本号 不带參数的 uptime 直接输出系统负载. 何为系统负载呢? 系统平均负载被定义为在特 ...