AVT相机arm版本SDK

This commit is contained in:
zhangpeng
2025-04-30 09:26:04 +08:00
parent 837c870f18
commit 78a1c63a95
705 changed files with 148770 additions and 0 deletions

View File

@@ -0,0 +1,256 @@
/*=============================================================================
Copyright (C) 2012 - 2016 Allied Vision Technologies. All Rights Reserved.
Redistribution of this file, in original or modified form, without
prior written consent of Allied Vision Technologies is prohibited.
-------------------------------------------------------------------------------
File: ApiController.cpp
Description: Implementation file for the ApiController helper class that
demonstrates how to implement a synchronous single image
acquisition with VimbaCPP.
-------------------------------------------------------------------------------
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE,
NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=============================================================================*/
#include <sstream>
#include <iostream>
#include "ApiController.h"
#include "Common/StreamSystemInfo.h"
#include "Common/ErrorCodeToMessage.h"
namespace AVT {
namespace VmbAPI {
namespace Examples {
enum { NUM_FRAMES = 3, };
ApiController::ApiController()
// Get a reference to the Vimba singleton
: m_system ( VimbaSystem::GetInstance() )
{
}
ApiController::~ApiController()
{
}
//
// Translates Vimba error codes to readable error messages
//
// Parameters:
// [in] eErr The error code to be converted to string
//
// Returns:
// A descriptive string representation of the error code
//
std::string ApiController::ErrorCodeToMessage( VmbErrorType eErr ) const
{
return AVT::VmbAPI::Examples::ErrorCodeToMessage( eErr );
}
//
// Starts the Vimba API and loads all transport layers
//
// Returns:
// An API status code
//
VmbErrorType ApiController::StartUp()
{
VmbErrorType res;
// Start Vimba
res = m_system.Startup();
if ( VmbErrorSuccess == res )
{
// This will be wrapped in a shared_ptr so we don't delete it
m_pCameraObserver = new CameraObserver();
// Register an observer whose callback routine gets triggered whenever a camera is plugged in or out
res = m_system.RegisterCameraListObserver( ICameraListObserverPtr( m_pCameraObserver ));
}
return res;
}
//
// Shuts down the API
//
void ApiController::ShutDown()
{
// Release Vimba
m_system.Shutdown();
}
//
// Opens the given camera
// Sets the maximum possible Ethernet packet size
// Adjusts the image format
// Calls the API convenience function to start single image acquisition
// Closes the camera in case of failure
//
// Parameters:
// [in] rStrCameraID The ID of the camera to work on
// [out] rpFrame The frame that will be filled. Does not need to be initialized.
//
// Returns:
// An API status code
//
VmbErrorType ApiController::AcquireSingleImage( const std::string &rStrCameraID, FramePtr &rpFrame )
{
// Open the desired camera by its ID
VmbErrorType res = m_system.OpenCameraByID( rStrCameraID.c_str(), VmbAccessModeFull, m_pCamera );
if ( VmbErrorSuccess == res )
{
// Set the GeV packet size to the highest possible value
// (In this example we do not test whether this cam actually is a GigE cam)
FeaturePtr pCommandFeature;
if ( VmbErrorSuccess == m_pCamera->GetFeatureByName( "GVSPAdjustPacketSize", pCommandFeature ))
{
if ( VmbErrorSuccess == pCommandFeature->RunCommand() )
{
bool bIsCommandDone = false;
do
{
if ( VmbErrorSuccess != pCommandFeature->IsCommandDone( bIsCommandDone ))
{
break;
}
} while ( false == bIsCommandDone );
}
}
FeaturePtr pFormatFeature;
// Save the current width
res = m_pCamera->GetFeatureByName( "Width", pFormatFeature );
if ( VmbErrorSuccess == res )
{
res = pFormatFeature->GetValue( m_nWidth );
if ( VmbErrorSuccess == res )
{
// Save the current height
res = m_pCamera->GetFeatureByName( "Height", pFormatFeature );
if ( VmbErrorSuccess == res )
{
pFormatFeature->GetValue( this->m_nHeight );
if ( VmbErrorSuccess == res )
{
// Set pixel format. For the sake of simplicity we only support Mono and RGB in this example.
res = m_pCamera->GetFeatureByName( "PixelFormat", pFormatFeature );
if ( VmbErrorSuccess == res )
{
// Try to set RGB
res = pFormatFeature->SetValue( VmbPixelFormatRgb8 );
if ( VmbErrorSuccess != res )
{
// Fall back to Mono
res = pFormatFeature->SetValue( VmbPixelFormatMono8 );
}
// Read back the currently selected pixel format
pFormatFeature->GetValue( m_nPixelFormat );
if ( VmbErrorSuccess == res )
{
// Acquire
res = m_pCamera->AcquireSingleImage( rpFrame, 2000 );
}
}
}
}
}
}
m_pCamera->Close();
}
return res;
}
//
// Calls the API convenience function to stop image acquisition
// Closes the camera
//
// Returns:
// An API status code
//
CameraPtrVector ApiController::GetCameraList() const
{
CameraPtrVector cameras;
// Get all known cameras
if ( VmbErrorSuccess == m_system.GetCameras( cameras ))
{
// And return them
return cameras;
}
return CameraPtrVector();
}
//
// Gets the width of a frame
//
// Returns:
// The width as integer
//
int ApiController::GetWidth() const
{
return static_cast<int>( m_nWidth );
}
//
// Gets the height of a frame
//
// Returns:
// The height as integer
//
int ApiController::GetHeight() const
{
return static_cast<int>( m_nHeight );
}
//
// Gets the pixel format of a frame
//
// Returns:
// The pixel format as enum
//
VmbPixelFormatType ApiController::GetPixelFormat() const
{
return static_cast<VmbPixelFormatType>( m_nPixelFormat );
}
//
// Returns the frame observer as QObject pointer to connect their signals to the view's slots
//
QObject* ApiController::GetCameraObserver()
{
return m_pCameraObserver;
}
//
// Gets the version of the Vimba API
//
// Returns:
// The version as string
//
std::string ApiController::GetVersion() const
{
std::ostringstream os;
os<<m_system;
return os.str();
}
}}} // namespace AVT::VmbAPI::Examples

View File

@@ -0,0 +1,152 @@
/*=============================================================================
Copyright (C) 2012 - 2016 Allied Vision Technologies. All Rights Reserved.
Redistribution of this file, in original or modified form, without
prior written consent of Allied Vision Technologies is prohibited.
-------------------------------------------------------------------------------
File: ApiController.h
Description: Implementation file for the ApiController helper class that
demonstrates how to implement a synchronous single image
acquisition with VimbaCPP.
-------------------------------------------------------------------------------
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE,
NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=============================================================================*/
#ifndef AVT_VMBAPI_EXAMPLES_APICONTROLLER
#define AVT_VMBAPI_EXAMPLES_APICONTROLLER
#include <string>
#include "VimbaCPP/Include/VimbaCPP.h"
#include "CameraObserver.h"
namespace AVT {
namespace VmbAPI {
namespace Examples {
class ApiController
{
public:
ApiController();
~ApiController();
//
// Starts the Vimba API and loads all transport layers
//
// Returns:
// An API status code
//
VmbErrorType StartUp();
//
// Shuts down the API
//
void ShutDown();
//
// Opens the given camera
// Sets the maximum possible Ethernet packet size
// Adjusts the image format
// Calls the API convenience function to start single image acquisition
// Closes the camera in case of failure
//
// Parameters:
// [in] rStrCameraID The ID of the camera to work on
// [out] rpFrame The frame that will be filled. Does not need to be initialized.
//
// Returns:
// An API status code
//
VmbErrorType AcquireSingleImage( const std::string &rStrCameraID, FramePtr &rpFrame );
//
// Gets the width of a frame
//
// Returns:
// The width as integer
//
int GetWidth() const;
//
// Gets the height of a frame
//
// Returns:
// The height as integer
//
int GetHeight() const;
//
// Gets the pixel format of a frame
//
// Returns:
// The pixel format as enum
//
VmbPixelFormatType GetPixelFormat() const;
//
// Calls the API convenience function to stop image acquisition
// Closes the camera
//
// Returns:
// An API status code
//
CameraPtrVector GetCameraList() const;
//
// Returns the frame observer as QObject pointer to connect their signals to the view's slots
//
QObject* GetCameraObserver();
//
// Translates Vimba error codes to readable error messages
//
// Parameters:
// [in] eErr The error code to be converted to string
//
// Returns:
// A descriptive string representation of the error code
//
std::string ErrorCodeToMessage( VmbErrorType eErr ) const;
//
// Gets the version of the Vimba API
//
// Returns:
// The version as string
//
std::string GetVersion() const;
private:
// A reference to our Vimba singleton
VimbaSystem & m_system;
// The currently streaming camera
CameraPtr m_pCamera;
// Our camera observer
CameraObserver* m_pCameraObserver;
// The current pixel format
VmbInt64_t m_nPixelFormat;
// The current width
VmbInt64_t m_nWidth;
// The current height
VmbInt64_t m_nHeight;
};
}}} // namespace AVT::VmbAPI::Examples
#endif

View File

@@ -0,0 +1,52 @@
/*=============================================================================
Copyright (C) 2012 - 2016 Allied Vision Technologies. All Rights Reserved.
Redistribution of this file, in original or modified form, without
prior written consent of Allied Vision Technologies is prohibited.
-------------------------------------------------------------------------------
File: CameraObserver.cpp
Description: The camera observer that is used for notifications from VimbaCPP
regarding a change in the camera list.
-------------------------------------------------------------------------------
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE,
NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=============================================================================*/
#include "CameraObserver.h"
namespace AVT {
namespace VmbAPI {
namespace Examples {
//
// This is our callback routine that will be executed every time a camera was plugged in or out
//
// Parameters:
// [in] pCam The camera that triggered the callback
// [in] reason The reason why the callback was triggered
//
void CameraObserver::CameraListChanged( CameraPtr pCam, UpdateTriggerType reason )
{
if ( UpdateTriggerPluggedIn == reason
|| UpdateTriggerPluggedOut == reason )
{
// Emit the new camera signal
emit CameraListChangedSignal( reason );
}
}
}}} // namespace AVT::VmbAPI::Examples

View File

@@ -0,0 +1,66 @@
/*=============================================================================
Copyright (C) 2012 - 2016 Allied Vision Technologies. All Rights Reserved.
Redistribution of this file, in original or modified form, without
prior written consent of Allied Vision Technologies is prohibited.
-------------------------------------------------------------------------------
File: CameraObserver.h
Description: The camera observer that is used for notifications from VimbaCPP
regarding a change in the camera list.
-------------------------------------------------------------------------------
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE,
NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=============================================================================*/
#ifndef AVT_VMBAPI_EXAMPLES_CAMERAOBSERVER
#define AVT_VMBAPI_EXAMPLES_CAMERAOBSERVER
#include <QObject>
#include "VimbaCPP/Include/VimbaCPP.h"
namespace AVT {
namespace VmbAPI {
namespace Examples {
class CameraObserver : public QObject, public ICameraListObserver
{
Q_OBJECT
public:
//
// This is our callback routine that will be executed every time a camera was plugged in or out
//
// Parameters:
// [in] pCam The camera that triggered the callback
// [in] reason The reason why the callback was triggered
//
virtual void CameraListChanged( CameraPtr pCamera, UpdateTriggerType reason );
signals:
//
// The camera list changed event (Qt signal) that notifies about a camera change and its reason
//
// Parameters:
// [out] reason The reason why this event was fired
//
void CameraListChangedSignal( int reason );
};
}}} // namespace AVT::VmbAPI::Examples
#endif

View File

@@ -0,0 +1,268 @@
/*=============================================================================
Copyright (C) 2012 - 2016 Allied Vision Technologies. All Rights Reserved.
Redistribution of this file, in original or modified form, without
prior written consent of Allied Vision Technologies is prohibited.
-------------------------------------------------------------------------------
File: SynchronousGrab.cpp
Description: Qt dialog class for the GUI of the SynchronousGrab example of
VimbaCPP.
-------------------------------------------------------------------------------
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE,
NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=============================================================================*/
#include <sstream>
#include "SynchronousGrab.h"
using AVT::VmbAPI::FramePtr;
using AVT::VmbAPI::CameraPtrVector;
enum { NUM_COLORS = 3, };
enum { BIT_DEPTH = 8, };
SynchronousGrab::SynchronousGrab(QWidget *parent, Qt::WindowFlags flags)
: QMainWindow(parent, flags)
, m_pApiController( new ApiController() )
{
ui.setupUi(this);
ui.m_LabelStream->setAlignment( Qt::AlignCenter );
// Connect GUI events with event handlers
QObject::connect( ui.m_ButtonStartStop, SIGNAL( clicked() ), this, SLOT( OnBnClickedButtonStartstop() ));
// Start Vimba
VmbErrorType err = m_pApiController->StartUp();
Log( "Starting Vimba", err );
if ( VmbErrorSuccess == err )
{
std::string WindowText("SynchronousGrab (Qt version) Vimba C++ API Version ");
WindowText += m_pApiController->GetVersion();
this->setWindowTitle( QString::fromStdString(WindowText) );
// Connect new camera found event with event handler
QObject::connect( m_pApiController->GetCameraObserver(), SIGNAL( CameraListChangedSignal( int )), this, SLOT( OnCameraListChanged( int )));
// Initially get all connected cameras
UpdateCameraListBox();
std::stringstream strMsg;
strMsg << "Cameras found..." << m_cameras.size();
Log( strMsg.str() );
}
}
SynchronousGrab::~SynchronousGrab()
{
// Before we close the application we stop Vimba
m_pApiController->ShutDown();
delete m_pApiController;
m_pApiController = NULL;
}
void SynchronousGrab::OnBnClickedButtonStartstop()
{
VmbErrorType err;
int nRow = ui.m_ListBoxCameras->currentRow();
if ( -1 < nRow )
{
// Get the frame
FramePtr pFrame;
err = m_pApiController->AcquireSingleImage( m_cameras[nRow], pFrame );
if ( VmbErrorSuccess == err )
{
// See if it is not corrupt
VmbFrameStatusType eReceiveStatus;
err = pFrame->GetReceiveStatus( eReceiveStatus );
if ( VmbErrorSuccess == err
&& VmbFrameStatusComplete == eReceiveStatus )
{
// Set up Qt image
QImage tmpImage( m_pApiController->GetWidth(),
m_pApiController->GetHeight(),
VmbPixelFormatRgb8 == m_pApiController->GetPixelFormat() ? QImage::Format_RGB888 : QImage::Format_Indexed8 );
if(VmbPixelFormatRgb8 != m_pApiController->GetPixelFormat())
{
tmpImage.setNumColors(256);
for(int i = 0; i < 256; i++)
{
tmpImage.setColor(i, qRgb(i, i, i));
}
}
VmbUchar_t *pBuffer;
err = pFrame->GetImage( pBuffer );
if ( VmbErrorSuccess == err )
{
VmbUint32_t nSize;
err = pFrame->GetImageSize( nSize );
if ( VmbErrorSuccess == err )
{
VmbPixelFormatType ePixelFormat = m_pApiController->GetPixelFormat();
if ( VmbPixelFormatMono8 == ePixelFormat
|| VmbPixelFormatRgb8 == ePixelFormat )
{
// Copy it
// We need that because Qt might repaint the view after we have released the frame already
CopyToImage( pBuffer, tmpImage );
// Display it
QSize s= ui.m_LabelStream->size();
ui.m_LabelStream->setPixmap( QPixmap::fromImage( tmpImage ).scaled( s, Qt::KeepAspectRatio) );
}
}
}
Log( "Starting Acquisition", err );
m_bIsStreaming = VmbErrorSuccess == err;
}
else
{
// If we receive an incomplete image we do nothing
err = VmbErrorOther;
}
}
Log( "Acquire single image", err );
}
else
{
Log( "Please select a camera." );
}
}
//
// This event handler (Qt slot) is triggered through a Qt signal posted by the camera observer
//
// Parameters:
// [in] reason The reason why the callback of the observer was triggered (plug-in, plug-out, ...)
//
void SynchronousGrab::OnCameraListChanged( int reason )
{
bool bUpdateList = false;
// We only react on new cameras being found and known cameras being unplugged
if ( AVT::VmbAPI::UpdateTriggerPluggedIn == reason )
{
Log( "Camera list changed. A new camera was discovered by Vimba." );
bUpdateList = true;
}
else if ( AVT::VmbAPI::UpdateTriggerPluggedOut == reason )
{
Log( "Camera list changed. A camera was disconnected from Vimba." );
bUpdateList = true;
}
if ( true == bUpdateList )
{
UpdateCameraListBox();
}
ui.m_ButtonStartStop->setEnabled( 0 < m_cameras.size() || m_bIsStreaming );
}
//
// Copies the content of a byte buffer to a Qt image with respect to the image's alignment
//
// Parameters:
// [in] pInbuffer The byte buffer as received from the cam
// [out] OutImage The filled Qt image
//
void SynchronousGrab::CopyToImage( VmbUchar_t *pInBuffer, QImage &OutImage )
{
VmbUchar_t * pCursor = OutImage.bits();
int nHeight = m_pApiController->GetHeight();
int nWidth = QImage::Format_Indexed8 == OutImage.format()
? m_pApiController->GetWidth()
: m_pApiController->GetWidth() * NUM_COLORS;
if ( OutImage.bytesPerLine() != nWidth )
{
for ( int y=0; y<nHeight; ++y )
{
pCursor = OutImage.scanLine( y );
for ( int x=0; x<nWidth; ++x )
{
*pCursor = *pInBuffer;
++pCursor;
++pInBuffer;
}
}
}
else
{
memcpy( OutImage.bits(), pInBuffer, nWidth * nHeight );
}
}
//
// Queries and lists all known camera
//
void SynchronousGrab::UpdateCameraListBox()
{
// Get all cameras currently connected to Vimba
CameraPtrVector cameras = m_pApiController->GetCameraList();
// Simply forget about all cameras known so far
ui.m_ListBoxCameras->clear();
m_cameras.clear();
// And query the camera details again
for ( CameraPtrVector::const_iterator iter = cameras.begin();
cameras.end() != iter;
++iter )
{
std::string strCameraName;
std::string strCameraID;
if ( VmbErrorSuccess != (*iter)->GetName( strCameraName ))
{
strCameraName = "[NoName]";
}
// If for any reason we cannot get the ID of a camera we skip it
if ( VmbErrorSuccess == (*iter)->GetID( strCameraID ))
{
ui.m_ListBoxCameras->addItem( QString::fromStdString( strCameraName + " " +strCameraID ) );
m_cameras.push_back( strCameraID );
}
}
ui.m_ButtonStartStop->setEnabled( 0 < m_cameras.size() || m_bIsStreaming );
}
//
// Prints out a given logging string, error code and the descriptive representation of that error code
//
// Parameters:
// [in] strMsg A given message to be printed out
// [in] eErr The API status code
//
void SynchronousGrab::Log( std::string strMsg, VmbErrorType eErr )
{
strMsg += "..." + m_pApiController->ErrorCodeToMessage( eErr );
ui.m_ListLog->insertItem( 0, QString::fromStdString( strMsg ) );
}
//
// Prints out a given logging string
//
// Parameters:
// [in] strMsg A given message to be printed out
//
void SynchronousGrab::Log( std::string strMsg )
{
ui.m_ListLog->insertItem( 0, QString::fromStdString( strMsg ) );
}

View File

@@ -0,0 +1,100 @@
/*=============================================================================
Copyright (C) 2012 - 2016 Allied Vision Technologies. All Rights Reserved.
Redistribution of this file, in original or modified form, without
prior written consent of Allied Vision Technologies is prohibited.
-------------------------------------------------------------------------------
File: SynchronousGrab.cpp
Description: Qt dialog class for the GUI of the SynchronousGrab example of
VimbaCPP.
-------------------------------------------------------------------------------
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE,
NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=============================================================================*/
#ifndef SYNCHRONOUSGRABQT_H
#define SYNCHRONOUSGRABQT_H
#include <QMainWindow>
#include "ui_SynchronousGrab.h"
#include "ApiController.h"
using AVT::VmbAPI::Examples::ApiController;
class SynchronousGrab : public QMainWindow
{
Q_OBJECT
public:
SynchronousGrab(QWidget *parent = 0, Qt::WindowFlags flags = 0);
~SynchronousGrab();
private:
Ui::SynchronousGrabClass ui;
// Our controller that wraps API access
ApiController * m_pApiController;
// A list of known camera IDs
std::vector<std::string> m_cameras;
// Are we streaming?
bool m_bIsStreaming;
//
// Queries and lists all known camera
//
void UpdateCameraListBox();
//
// Prints out a given logging string, error code and the descriptive representation of that error code
//
// Parameters:
// [in] strMsg A given message to be printed out
// [in] eErr The API status code
//
void Log( std::string strMsg, VmbErrorType eErr );
//
// Prints out a given logging string
//
// Parameters:
// [in] strMsg A given message to be printed out
//
void Log( std::string strMsg );
//
// Copies the content of a byte buffer to a Qt image with respect to the image's alignment
//
// Parameters:
// [in] pInbuffer The byte buffer as received from the cam
// [out] OutImage The filled Qt image
//
void CopyToImage( VmbUchar_t *pInBuffer, QImage &OutImage );
private slots:
void OnBnClickedButtonStartstop();
//
// This event handler (Qt slot) is triggered through a Qt signal posted by the camera observer
//
// Parameters:
// [in] reason The reason why the callback of the observer was triggered (plug-in, plug-out, ...)
//
void OnCameraListChanged( int reason );
};
#endif // SYNCHRONOUSGRABQT_H

View File

@@ -0,0 +1,37 @@
/*=============================================================================
Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
Redistribution of this file, in original or modified form, without
prior written consent of Allied Vision Technologies is prohibited.
-------------------------------------------------------------------------------
File: main.cpp
Description: The main entry point of the SynchronousGrab example of VimbaCPP.
-------------------------------------------------------------------------------
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE,
NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=============================================================================*/
#include "SynchronousGrab.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
SynchronousGrab w;
w.show();
return a.exec();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/SynchronousGrabQt">
<file>SynchronousGrab.png</file>
</qresource>
</RCC>

View File

@@ -0,0 +1,98 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SynchronousGrabClass</class>
<widget class="QMainWindow" name="SynchronousGrabClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1040</width>
<height>780</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>1040</width>
<height>780</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>1040</width>
<height>780</height>
</size>
</property>
<property name="windowTitle">
<string>SynchronousGrab (Qt version)</string>
</property>
<property name="windowIcon">
<iconset resource="SynchronousGrab.qrc">
<normaloff>:/SynchronousGrabQt/SynchronousGrab.png</normaloff>:/SynchronousGrabQt/SynchronousGrab.png</iconset>
</property>
<widget class="QWidget" name="centralWidget">
<widget class="QListWidget" name="m_ListBoxCameras">
<property name="geometry">
<rect>
<x>0</x>
<y>10</y>
<width>261</width>
<height>521</height>
</rect>
</property>
</widget>
<widget class="QListWidget" name="m_ListLog">
<property name="geometry">
<rect>
<x>0</x>
<y>580</y>
<width>1041</width>
<height>191</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="m_ButtonStartStop">
<property name="geometry">
<rect>
<x>0</x>
<y>540</y>
<width>261</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>Acquire Single Image</string>
</property>
</widget>
<widget class="QLabel" name="m_LabelStream">
<property name="geometry">
<rect>
<x>270</x>
<y>10</y>
<width>771</width>
<height>561</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>
<include location="SynchronousGrab.qrc"/>
</resources>
<connections/>
</ui>