Skip to content
Snippets Groups Projects
Commit 790a92f6 authored by am0ebe's avatar am0ebe
Browse files

[wip] get frames, acquire images

parent 9af1281d
Branches
No related tags found
No related merge requests found
......@@ -39,7 +39,6 @@ void Core::initCams()
camIdx = 0; //dflt to 1rst
curCam = cameras.at(camIdx);
}
}
else
{
......@@ -62,14 +61,6 @@ CameraPtr Core::cam()
return cameras.at(camIdx);
}
void Core::setCam(ulong idx)
{
if( idx >= cameras.size() )
idx = cameras.size() - 1;
camIdx = idx;
}
void Core::listCams()
{
......@@ -150,8 +141,14 @@ void Core::printHelp()
void Core::openCam()
{
const QString str = "camOpened(camIdx)";
emit print(str);
auto ret = curCam->Open( VmbAccessModeFull );
if ( VmbErrorSuccess != ret )
{
qDebug() << "Couldn't open camera";
return;
}
emit print("camOpened("+QString::number(camIdx)+")");
}
void Core::selectCam(const int& camIdx)
......@@ -162,16 +159,59 @@ void Core::selectCam(const int& camIdx)
}
catch (const std::out_of_range& oor)
{
// QString str = "invalid camIdx" + QString::fromStdString(oor.what());
emit err("oops!",errCamIdx);
return;
}
emit print("camSelected("+QString::number(camIdx)+")");
}
void Core::start_recording()
{
VmbInt64_t nPLS; // Payload size value
FeaturePtr pFeature ; // Generic feature pointer
FramePtrVector frames (15); // Frame array
// Get the image size for the required buffer
// Allocate memory for frame buffer
// Register frame observer / callback for each frame
// Announce frame to the API
curCam->GetFeatureByName (" PayloadSize ", pFeature );
pFeature -> GetValue (nPLS );
for( FramePtrVector :: iterator iter= frames .begin (); frames .end () != iter; ++ iter)
{
(* iter ).reset(new Frame (nPLS));
(* iter)-> RegisterObserver ( IFrameObserverPtr (new FrameObserver ( curCam)));
curCam-> AnnounceFrame (* iter );
}
if( camIdx >= (int)cameras.size() )
// Start the capture engine (API)
curCam-> StartCapture ();
for( FramePtrVector :: iterator iter= frames .begin (); frames .end ()!= iter; ++ iter)
{
return;
// Put frame into the frame queue
curCam->QueueFrame (* iter );
}
// ->Open(VmbAccessModeFull);
// Start the acquisition engine ( curCam)
curCam-> GetFeatureByName (" AcquisitionStart ", pFeature );
pFeature -> RunCommand ();
// Program runtime , e.g., Sleep (2000);
// Stop the acquisition engine ( curCam)
curCam-> GetFeatureByName (" AcquisitionStop ", pFeature );
pFeature -> RunCommand ();
const QString str = "camSelected("+QString::number(camIdx)+")";
emit print(str);
// Stop the capture engine (API)
// Flush the frame queue
// Revoke all frames from the API
curCam-> EndCapture ();
curCam-> FlushQueue ();
curCam-> RevokeAllFrames ();
for( FramePtrVector :: iterator iter= frames .begin (); frames .end ()!= iter; ++ iter)
{
// Unregister the frame observer / callback
(* iter)-> UnregisterObserver ();
}
}
......@@ -26,6 +26,8 @@ class Core : public QObject
void openCam();
void selectCam(const int &);
void start_recording();
signals:
void print(const QString &);
void printList(QStringList);
......@@ -35,7 +37,6 @@ class Core : public QObject
void initCams();
void getCamInfo( const CameraPtr & );
CameraPtr cam();
void setCam(ulong idx);
bool apiStarted;
VmbCPP::VmbSystem& sys;
......
#include "frameObserver.h"
#include <VmbCPP/SharedPointerDefines.h>
using namespace VmbCPP;
FrameObserver::FrameObserver( CameraPtr pCamera ) : IFrameObserver( pCamera )
{
}
// Frame callback notifies about incoming frames
void FrameObserver::FrameReceived ( const FramePtr pFrame )
{
// Send notification to working thread
// Do not apply image processing within this callback ( performance )
// When the frame has been processed , requeue it
m_pCamera -> QueueFrame ( pFrame );
}
#pragma once
#include <VmbCPP/IFrameObserver.h>
using VmbCPP::CameraPtr;
using VmbCPP::FramePtr;
using VmbCPP::IFrameObserver;
class FrameObserver : IFrameObserver
{
FrameObserver( CameraPtr pCamera );
void FrameReceived( const FramePtr pFrame );
};
......@@ -20,11 +20,11 @@ void FrameObserver::FrameReceived ( const FramePtr pFrame )
void Vimba::RunExample (void)
{
VmbInt64_t nPLS; // Payload size value
FeaturePtr pFeature ; // Generic feature pointer
VmbSystem &sys = VmbSystem :: GetInstance (); // Create and get Vimba singleton
CameraPtrVector cameras ; // Holds camera handles
CameraPtr camera ;
VmbInt64_t nPLS; // Payload size value
FeaturePtr pFeature ; // Generic feature pointer
FramePtrVector frames (15); // Frame array
// Start the API , get and open cameras
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment